Skip to content

Commit

Permalink
154 fix testbank for py39 and higher versions (#155)
Browse files Browse the repository at this point in the history
* test on None instead of nan

* fix for py38 also
  • Loading branch information
veenstrajelmer authored Nov 8, 2023
1 parent d239b99 commit 42c9e23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hatyan/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def metadata_from_diablocks(diablocks_pd, block_id):

# replace nan with None (otherwise metadata_compare fails)
#TODO: avoid nan in metadata (timestep for hoek_har.dia)
if np.isnan(metadata['timestep_min']):
if np.isnan(metadata['timestep_min']): #non-equidistant, nan in py38 and none in py39 (pandas 2.1.2)
metadata['timestep_min'] = None
metadata['timestep_unit'] = None
return metadata
Expand Down
6 changes: 3 additions & 3 deletions hatyan/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@ def get_diablocks(filename):
datestart = dt.datetime.strptime(data_meta_mincontent[1]+data_meta_mincontent[2], "%Y%m%d%H%M")
datestop = dt.datetime.strptime(data_meta_mincontent[3]+data_meta_mincontent[4], "%Y%m%d%H%M")
if len(data_meta_mincontent)==5: #nonequidistant timeseries
timestep_value = None
timestep_unit = None
timestep_value = np.nan #TODO: None is supported by pandas 2.1.2 and maybe earlier versions, but not 2.0.3 (py39 only)
timestep_unit = np.nan
elif len(data_meta_mincontent)==7: #equidistant timeseries contains also timeunit and timestep
timestep_unit = data_meta_mincontent[6]
if timestep_unit not in ['min','cs']: #minutes and 1/100 sec
Expand Down Expand Up @@ -1579,7 +1579,7 @@ def readts_dia(filename, station=None, block_ids=None, get_status=False, allow_d
f"{str_getdiablockspd}")

for block_id in block_ids:
if np.isnan(diablocks_pd.loc[block_id,'timestep_min']): #non-equidistant
if np.isnan(diablocks_pd.loc[block_id,'timestep_min']):
data_pd_oneblock = readts_dia_nonequidistant(filename_one, diablocks_pd, block_id)
else: #equidistant
data_pd_oneblock = readts_dia_equidistant(filename_one, diablocks_pd, block_id)
Expand Down

0 comments on commit 42c9e23

Please sign in to comment.