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

Python: len(series) #1375

Closed
ax3l opened this issue Feb 14, 2023 · 1 comment · Fixed by #1659
Closed

Python: len(series) #1375

ax3l opened this issue Feb 14, 2023 · 1 comment · Fixed by #1659

Comments

@ax3l
Copy link
Member

ax3l commented Feb 14, 2023

We should consider if we want to overwrite the __len__/len() of openPMD_api.Series.

Currently, it (probably) returns the number of attributes as for all Attributable objects in openPMD.

It might be maybe a bit more intuitive if it returns the len(series.iterations) instead.

First seen by @RTSandberg .

Refs.:

@ax3l ax3l added this to the 0.16.0 milestone Feb 14, 2023
@ax3l ax3l added the question label Feb 14, 2023
@franzpoeschel
Copy link
Contributor

franzpoeschel commented Feb 21, 2023

We should generally do an overhaul of our object model in Python. The string representations of many classes are counterintuitive and have led to confusion, e.g. series.iterations printed will look as if it is empty:

> s.iterations
<openPMD.Attributable with '0' attributes>
>>> s.iterations[0]
<openPMD.Iteration at t = '0.000000e+00 s'>

Also, now that we have done a redesign of our C++ object model, we can introduce proper semantics for equality comparison. I recently wanted to use record components as keys in a Python dict, this currently leads to crashes. --> #1658

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

Successfully merging a pull request may close this issue.

2 participants