Skip to content

Commit

Permalink
Merge pull request #11 from GEUS-Glaciology-and-Climate/fix-numpy-float
Browse files Browse the repository at this point in the history
Fix numpy float
  • Loading branch information
BaptisteVandecrux authored Jan 13, 2023
2 parents d42c101 + 0f7e910 commit d811220
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nead/nead.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def read(neadfile, MKS=None, multi_index=True, index_col=None):

# Convert from string to number if it is a number
if val.strip('-').strip('+').replace('.','').isdigit():
val = np.float(val)
if val == np.int(val):
val = np.int(val)
val = float(val)
if val == int(val):
val = int(val)

if section == 'meta': meta[key] = val
if section == 'fields': fields[key] = val
Expand Down Expand Up @@ -96,9 +96,9 @@ def read(neadfile, MKS=None, multi_index=True, index_col=None):
if all([str(s).strip('-').strip('+').replace('.','').isdigit() or str(s) == "" for s in arr]):
arr = np.array(arr).astype("<U32")
arr[arr == ""] = 'nan'
arr = arr.astype(np.float)
if all(arr == arr.astype(np.int)):
arr = arr.astype(np.int)
arr = arr.astype(float)
if all(arr == arr.astype(int)):
arr = arr.astype(int)

for i,v in enumerate(ds.data_vars):
# print(i,v)
Expand Down

0 comments on commit d811220

Please sign in to comment.