In [2]:
import numpy
import itertools

In [28]:
def make_all_variants(points_list):
    total_list = [[] for _ in range(len(points_list))]
    for cur_point in points_list[0]:
        if len(points_list) == 2:
            total_list = make_all_variants_2d(points_list[0], points_list[1])
        else:
            temp_res = make_all_variants(points_list[1:])
            total_list[0].extend(itertools.repeat(cur_point, len(temp_res[0])))
            for i in range(1, len(total_list)):
                total_list[i].extend(temp_res[i - 1])
    return total_list

In [9]:
def make_all_variants_2d(points1, points2):
    output_list = [[], []]
    for point in points1:
        output_list[0].extend(itertools.repeat(point, len(points2)))
        output_list[1].extend(points2)
    return output_list

In [36]:
def make_grid(lens_list, a, b):
    points_list = []
    for cur_len in lens_list:
        points_list.append(numpy.linspace(a, b, cur_len))
    print(points_list)
    return make_all_variants(points_list)

In [4]:
list(itertools.repeat(3, 5))


Out[4]:
[3, 3, 3, 3, 3]

In [33]:
x = numpy.array([0, 1, 2])
y = numpy.array([3, 4])
z = numpy.array([5, 6, 7, 8])

In [34]:
make_all_variants_2d(x, y)


Out[34]:
[[0, 0, 1, 1, 2, 2], [3, 4, 3, 4, 3, 4]]

In [35]:
numpy.array(make_all_variants([x, y, z]))


Out[35]:
array([[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
        2, 2],
       [3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4,
        4, 4],
       [5, 6, 7, 8, 5, 6, 7, 8, 5, 6, 7, 8, 5, 6, 7, 8, 5, 6, 7, 8, 5, 6,
        7, 8]])

In [43]:
numpy.array(make_grid([3, 5, 2], -10, 10))


[array([-10.,   0.,  10.]), array([-10.,  -5.,   0.,   5.,  10.]), array([-10.,  10.])]
Out[43]:
array([[-10., -10., -10., -10., -10., -10., -10., -10., -10., -10.,   0.,
          0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,  10.,  10.,
         10.,  10.,  10.,  10.,  10.,  10.,  10.,  10.],
       [-10., -10.,  -5.,  -5.,   0.,   0.,   5.,   5.,  10.,  10., -10.,
        -10.,  -5.,  -5.,   0.,   0.,   5.,   5.,  10.,  10., -10., -10.,
         -5.,  -5.,   0.,   0.,   5.,   5.,  10.,  10.],
       [-10.,  10., -10.,  10., -10.,  10., -10.,  10., -10.,  10., -10.,
         10., -10.,  10., -10.,  10., -10.,  10., -10.,  10., -10.,  10.,
        -10.,  10., -10.,  10., -10.,  10., -10.,  10.]])

In [ ]: