From 42c9e23bca48eb4dd72c7095233f4395e281244f Mon Sep 17 00:00:00 2001 From: veenstrajelmer <60435591+veenstrajelmer@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:15:35 +0100 Subject: [PATCH] 154 fix testbank for py39 and higher versions (#155) * test on None instead of nan * fix for py38 also --- hatyan/metadata.py | 2 +- hatyan/timeseries.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hatyan/metadata.py b/hatyan/metadata.py index 36499b3a..16585f4f 100644 --- a/hatyan/metadata.py +++ b/hatyan/metadata.py @@ -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 diff --git a/hatyan/timeseries.py b/hatyan/timeseries.py index 97282b2f..a94d8e92 100644 --- a/hatyan/timeseries.py +++ b/hatyan/timeseries.py @@ -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 @@ -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)