pastas / pastastore

:spaghetti: :convenience_store: Tools for managing timeseries and Pastas models

Home Page:https://pastastore.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] Force Data type of oseries index to strings

raoulcollenteur opened this issue · comments

Finally got to move some projects to Pastastore, works very well two far! Small issue here:

I have time series with numbers as series name. Although I force these numbers to be strings, this may still cause failure at a later stage (e.g., store.get_statistics(["evp"]).

It would be nicety simply force the index of store.oseries to strings, to prevent any issues.

I saw you self-assigned this, but since I was in the middle of a big (internal) update, I figured I'd add the fix for this.

Both the _add_series and add_model methods now force name to be of type str. This won't fix old pastastores with non-str names, but for new ones this should take care of things?

PS. can you let met know if this fixes it? I want to make a new release soon and it would be nice to include this fix.

The fix unfortunately does not work for the models I am testing it on.

Seems to be going wrong in line :

name = mdict["oseries"]['name']

I think this is because we don't enforce strings in Pastas itself right>? Maybe we should fix it there..

just checked: name = str(mdict["oseries"]['name']) fixes it.

mdict is from a .pas file right? If so, I think we should open a new issue in pastas and fix it there.

That makes sense, my change only fixed it on the pastastore side, not in the pastas model oseries. Can you commit the change (and maybe also for the stresses)?

mdict is from a pas file yes, it is basically the result of pastas.Model.to_dict(series=False)

Just committed the fix. However, I will open an issue in Pastas, to double check data types when reading models from .pas-files with ps.load_model.