diff --git a/fipy/meshes/grid1D.py b/fipy/meshes/grid1D.py index 886a0bb3c8..a1ed31a68e 100644 --- a/fipy/meshes/grid1D.py +++ b/fipy/meshes/grid1D.py @@ -1,4 +1,4 @@ from __future__ import unicode_literals from fipy.meshes.nonUniformGrid1D import NonUniformGrid1D as Grid1D import warnings -warnings.warn("Grid1D has been deprecated use NonUniformGrid1D instead.", stacklevel=3) +warnings.warn("Grid1D has been deprecated use NonUniformGrid1D instead.", stacklevel=3) \ No newline at end of file diff --git a/fipy/meshes/nonUniformGrid1D.py b/fipy/meshes/nonUniformGrid1D.py index 2db4f6a1d7..39f5d8ee93 100644 --- a/fipy/meshes/nonUniformGrid1D.py +++ b/fipy/meshes/nonUniformGrid1D.py @@ -38,6 +38,9 @@ def __init__(self, dx=1., nx=None, overlap=2, _BuilderClass=_NonuniformGrid1DBuilder, _RepresentationClass=_Grid1DRepresentation, _TopologyClass=_Grid1DTopology): + + if not isinstance(nx, int) or nx < 0: + raise ValueError("nx must be a non-negative integer") builder = _BuilderClass() diff --git a/fipy/meshes/nonUniformGrid2D.py b/fipy/meshes/nonUniformGrid2D.py index f0210924b7..3db4c83f97 100644 --- a/fipy/meshes/nonUniformGrid2D.py +++ b/fipy/meshes/nonUniformGrid2D.py @@ -22,6 +22,8 @@ class NonUniformGrid2D(Mesh2D): """ def __init__(self, dx=1., dy=1., nx=None, ny=None, overlap=2, communicator=parallelComm, _RepresentationClass=_Grid2DRepresentation, _TopologyClass=_Grid2DTopology): + if (not isinstance(nx, int) or nx < 0) and (not isinstance(ny, int) or ny < 0): + raise ValueError("nx must be a non-negative integer") builder = _NonuniformGrid2DBuilder() diff --git a/fipy/meshes/nonUniformGrid3D.py b/fipy/meshes/nonUniformGrid3D.py index 3e42df3dac..8a9e94bc3e 100644 --- a/fipy/meshes/nonUniformGrid3D.py +++ b/fipy/meshes/nonUniformGrid3D.py @@ -32,6 +32,9 @@ class NonUniformGrid3D(Mesh): def __init__(self, dx = 1., dy = 1., dz = 1., nx = None, ny = None, nz = None, overlap=2, communicator=parallelComm, _RepresentationClass=_Grid3DRepresentation, _TopologyClass=_Grid3DTopology): + if (not isinstance(nx, int) or nx < 0) and (not isinstance(ny, int) or ny < 0) and (not isinstance(nz, int) or nz < 0): + raise ValueError("nx must be a non-negative integer") + builder = _NonuniformGrid3DBuilder() self.args = {