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

problems with float to int conversion when reading pastastore from zip #108

Closed
OnnoEbbens opened this issue Nov 14, 2023 · 2 comments
Closed

Comments

@OnnoEbbens
Copy link
Member

I have a stress consisting of integers. To avoid any pastas validation errors I convert the stress from integers to floats before I add it to the pastastore. I save the pastastore to a .zip file and then I get an error when I try to read it from the .zip. When the stress is read from the zip file it is converted back from floats to integers which results in an error when validating the series in pastas.

to reproduce:

import pastastore as pst
import pandas as pd
df = pd.DataFrame(np.random.randint(0, 100, 100), index=pd.date_range('2000-1-1' ,periods=100))
# create PastaStore instance
pstore = pst.PastaStore(pst.DictConnector())

pstore.add_stress(df.astype(float), "evap", kind="evap", metadata={"x": 100_000, "y": 400_000})


pstore.to_zip('pstore.zip')
pstore_in = pst.PastaStore.from_zip("pstore.zip", conn=pst.DictConnector())
OnnoEbbens added a commit that referenced this issue Nov 14, 2023
@dbrakenhoff
Copy link
Member

Perhaps Pastas checking if the time series has dtype float is too harsh? If we also allow ints in the validate series function this problem would also be solved? But I'm okay with implementing your proposed fix here too.

dbrakenhoff added a commit that referenced this issue Nov 14, 2023
…nversion-when-reading-pastastore-from-zip

fix for #108
@dbrakenhoff
Copy link
Member

Fixed by #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants