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

Dict: implement items() method #5333

Merged
merged 1 commit into from
Jan 26, 2022
Merged

Conversation

mbercx
Copy link
Member

@mbercx mbercx commented Jan 26, 2022

Fixes #5332

This allows the user to directly iterate over the Dict items instead
of first retrieving the dict with get_dict() method:

In [1]: d = Dict({'a': 1, 'b': {'c': 2}})

In [2]: for k, v in d.items():
   ...:     print(k, v)
   ...:
a 1
b {'c': 2}

This allows the user to directly iterate over the `Dict` items instead
of first retrieving the `dict` with `get_dict()` method:

```python
In [1]: d = Dict({'a': 1, 'b': {'c': 2}})

In [2]: for k, v in d.items():
   ...:     print(k, v)
   ...:
a 1
b {'c': 2}
```
@mbercx mbercx requested a review from sphuber January 26, 2022 09:03
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely spiffing!

@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #5333 (b6f647a) into develop (af3bb3d) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5333      +/-   ##
===========================================
- Coverage    82.11%   82.11%   -0.00%     
===========================================
  Files          533      533              
  Lines        38429    38432       +3     
===========================================
+ Hits         31554    31555       +1     
- Misses        6875     6877       +2     
Flag Coverage Δ
django 77.19% <100.00%> (-<0.01%) ⬇️
sqlalchemy 76.49% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiida/orm/nodes/data/dict.py 88.89% <100.00%> (+0.66%) ⬆️
aiida/engine/daemon/client.py 75.38% <0.00%> (-1.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af3bb3d...b6f647a. Read the comment docs.

@sphuber sphuber merged commit 2003b99 into aiidateam:develop Jan 26, 2022
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

Successfully merging this pull request may close these issues.

Dict: Add items() iterator
2 participants