Skip to content

Commit

Permalink
fix(cellid): Fixes some issues with flopy properly identifying cell i…
Browse files Browse the repository at this point in the history
…ds (#1335) (#1336)
  • Loading branch information
spaulins-usgs committed Jan 25, 2022
1 parent 0616db5 commit 33e61b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion flopy/mf6/data/mfdatalist.py
Expand Up @@ -1423,7 +1423,10 @@ def data_type(self):
def dtype(self):
data = self.get_data()
if len(data) > 0:
return data[0].dtype
if 0 in data:
return data[0].dtype
else:
return next(iter(data.values())).dtype
else:
return None

Expand Down
14 changes: 12 additions & 2 deletions flopy/mf6/data/mfstructure.py
Expand Up @@ -928,7 +928,11 @@ def set_value(self, line, common):
self.name_list.append(self.name)
if len(self.name) >= 6 and self.name[0:6] == "cellid":
self.is_cellid = True
if self.name and self.name[0:2] == "id":
if (
self.name
and self.name[0:2] == "id"
and self.type == DatumType.string
):
self.possible_cellid = True
self.python_name = self.name.replace("-", "_").lower()
# don't allow name to be a python keyword
Expand Down Expand Up @@ -961,6 +965,12 @@ def set_value(self, line, common):
)
self.type_string = type_line[0].lower()
self.type = self._str_to_enum_type(type_line[0])
if (
self.name
and self.name[0:2] == "id"
and self.type == DatumType.string
):
self.possible_cellid = True
if (
self.type == DatumType.recarray
or self.type == DatumType.record
Expand Down Expand Up @@ -1261,7 +1271,7 @@ def _str_to_enum_type(self, type_string):

def get_rec_type(self):
item_type = self.type_obj
if item_type == str or self.is_cellid:
if item_type == str or self.is_cellid or self.possible_cellid:
return object
return item_type

Expand Down

0 comments on commit 33e61b8

Please sign in to comment.