Skip to content

Commit

Permalink
refactor flatfile io WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rizac committed Sep 23, 2023
1 parent 321ca52 commit 35656bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions egsim/smtk/flatfile/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,10 @@ def _cast_dtype(dtype: Union[list, tuple, str, pd.CategoricalDtype, ColumnDtype]
if isinstance(dtype, ColumnDtype):
return dtype
if isinstance(dtype, str):
for val in ColumnDtype:
if val == dtype or val.name == dtype: # noqa
return val # noqa
try:
return ColumnDtype[dtype] # try enum name (raise KeyError)
except KeyError:
return ColumnDtype(dtype) # try enum value (raises ValueError)
if isinstance(dtype, (list, tuple)):
dtype = pd.CategoricalDtype(dtype)
if isinstance(dtype, pd.CategoricalDtype):
Expand Down

0 comments on commit 35656bf

Please sign in to comment.