Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

154 fix testbank for py39 and higher versions #155

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading