-
Notifications
You must be signed in to change notification settings - Fork 3
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-like methods of Dataset
.
#153
Conversation
…n into dict-like-methods
src/scitacean/dataset.py
Outdated
def keys(self) -> Iterable[str]: | ||
"""Dict-like keys(names of fields) method. | ||
|
||
.. versionadded:: RELEASE_PLACEHOLDER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move those directives to the very end of the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it doesn't work if it is not above the sub-titles...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an annoyance with restructured text. You need two empty lines to 'return' from the previous section. I just added this to the coding conventions: https://github.com/SciCatProject/scitacean/blob/main/docs/developer/coding-conventions.rst
Can you add a release note? |
Co-authored-by: Jan-Lukas Wynen <jan-lukas.wynen@ess.eu>
Co-authored-by: Jan-Lukas Wynen <jan-lukas.wynen@ess.eu>
@jl-wynen I'm not authorized to merge this PR...! |
Fixes #76
During the sprint
Dict-like methods:
keys
values
items
__getitem__
__setitem__
We decided not to include this one.setdefault
Helper method to check if the key to the
__(get/set)item__
is valid:_validate_field_name
keys
/values
/items
keys
return names of fields that belong to the currenttype
of theDataset
object and other fields that only belong to the othertype
only if they are notNone
.values
anditems
are usingkeys
, hence using same set of fields.__getitem__
/__setitem__
/setdefault
These methods check if the
key
(field_name
) is one of names of fields defined in theDatasetBase._FIELD_SPEC
.If not valid, raise
KeyError
with custom error message.But these methods don't check if they are valid fields of the current
type
.Manual fields
Fields that are not defined in the
DatasetBase._FIELD_SPEC
are excluded for now. See #151 for more detail.