warn if grid is going to be int-typed

This commit is contained in:
jan 2017-09-05 11:08:06 -07:00
parent e930baf2b4
commit 3d36f66a39

View File

@ -322,6 +322,8 @@ class Grid(object):
grids_shape = hstack((num_grids, self.shape)) grids_shape = hstack((num_grids, self.shape))
if is_scalar(initial): if is_scalar(initial):
if isinstance(initial, int):
warnings.warn('Initial value is an int, grids will be integer-typed!')
self.grids = numpy.full(grids_shape, initial) self.grids = numpy.full(grids_shape, initial)
else: else:
if len(initial) < num_grids: if len(initial) < num_grids:
@ -331,6 +333,8 @@ class Grid(object):
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:
if isinstance(initial[i], int):
warnings.warn('Initial value is an int, grid {} will be integer-typed!'.format(i))
self.grids[i] = numpy.full(self.shape, initial[i]) self.grids[i] = numpy.full(self.shape, initial[i])
else: else:
if not numpy.array_equal(initial[i].shape, self.shape): if not numpy.array_equal(initial[i].shape, self.shape):