equinor / xtgeo

XTGeo Python class library for subsurface Surfaces, Cubes, Wells, Grids, Points, etc
https://xtgeo.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
110 stars 56 forks source link

Raise an exception if a `GridProperty` is initialized with uncovered non-dummy values #1115

Closed mferrera closed 6 months ago

mferrera commented 8 months ago

If a GridProperty is initialized with values set to some unaccounted for data type (e.g. an xarray Dataset)

gp = xtgeo.GridProperty(1, 2, 3, values=xr.Dataset(...))

the following function tries to return a variable that was never assigned when setting up the values

https://github.com/equinor/xtgeo/blob/fc37c4c67eb2e52486fc83d743ab4705dadd16b2/src/xtgeo/grid3d/_gridprop_value_init.py#L37-L52

UnboundLocalError: local variable '_values' referenced before assignment