Skip to content

StructuredGrid.get_coords fails with array-like of ints #1113

@wkitlasten

Description

@wkitlasten

get_coords fails if x and y are lists of ints and set_coord_info() has not been set:

delc = 10*np.ones(10, dtype=float)
delr = 10*np.ones(10, dtype=float)
xoff = 0.
yoff = 0.
angrot = 0.
sgr = fgrid.StructuredGrid(delc, delr, top=None, botm=None, xoff=xoff, yoff=yoff, angrot=angrot, epsg=1894)
x=[1,2,3]
y=[4,5,6]
sgr.get_coords(x=x,y=y)
---------------------------------------------------------------------------
UFuncTypeError                            Traceback (most recent call last)
<ipython-input-38-9bf2b701fd4c> in <module>
      1 x=[1,2,3]
      2 y=[4,5,6]
----> 3 sgr.get_coords(x=x,y=y)

D:\git\flopy\flopy\discretization\grid.py in get_coords(self, x, y)
    561             x, y = x.copy(), y.copy()
    562 
--> 563         x += self._xoff
    564         y += self._yoff
    565         return geometry.rotate(

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int32') with casting rule 'same_kind'

set_coord_info() before get_coords does not fail:

sgr.set_coord_info(xoff=10000, yoff=10000, 
                           angrot=0, epsg=1234)
sgr.get_coords(x=x,y=y)

(array([10001., 10002., 10003.]), array([10004., 10005., 10006.]))

passing lists of floats also does not fail:

x=[1.,2.,3.]
y=[4.,5.,6.]
(array([10001., 10002., 10003.]), array([10004., 10005., 10006.]))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions