Make .grids an ndarray instead of a list-of-ndarrays

This commit is contained in:
Jan Petykiewicz 2019-09-30 23:34:49 -07:00
parent 4b301b2dd5
commit 0c4a773b84

View File

@ -47,7 +47,7 @@ class Grid(object):
exyz = [] # type: List[numpy.ndarray] exyz = [] # type: List[numpy.ndarray]
# epsilon (or mu, or whatever) grids # epsilon (or mu, or whatever) grids
grids = [] # type: List[numpy.ndarray] grids = [] # type: numpy.ndarray
# [[x0 y0 z0], [x1, y1, z1], ...] offsets for grid 0,1,... # [[x0 y0 z0], [x1, y1, z1], ...] offsets for grid 0,1,...
shifts = None # type: numpy.ndarray shifts = None # type: numpy.ndarray
@ -265,7 +265,7 @@ class Grid(object):
if len(initial) < num_grids: if len(initial) < num_grids:
raise GridError('Too few initial grids specified!') raise GridError('Too few initial grids specified!')
self.grids = [None] * num_grids self.grids = numpy.empty(grids_shape)
for i in range(num_grids): for i in range(num_grids):
if is_scalar(initial[i]): if is_scalar(initial[i]):
if initial[i] is not None: if initial[i] is not None: