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

DM-19873: Resurrect get() and add __getitem__ calling it #50

Merged
merged 4 commits into from May 28, 2019

Conversation

timj
Copy link
Member

@timj timj commented May 24, 2019

get() now matches the dict.get API except that it always
calls getScalar internally whilst also providing a default
value.

The tests have been modified accordingly and the deprecation
message has been removed.

Copy link
Contributor

@r-owen r-owen left a comment

Choose a reason for hiding this comment

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

Overall this looks great.

I have two significant requests:

  • Please add unit tests for get(key, default). I am sorry if they are present and I missed them.
  • Please consider dropping update unless you really need it. PropertyList and PropertySet are only "sort of" dicts and I worry that the more methods are added to make them the same the more likely folks will be caught out by the differences.

Other than that I just had a few requests for expanded documentation.

self.combine(addition)
else:
for k, v in addition.items():
self[k] = v
Copy link
Contributor

Choose a reason for hiding this comment

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

I would be much happier if you omitted this unless you really need it. I think it goes a bit too far in treating PropertySet like a dict.

What does this do if the key already exists? Does this add the new value or replace the existing values? If you must have this then please be much more explicit about its behavior in the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add more explanation. I added this because I had a direct need for it.

@@ -501,6 +534,9 @@ def __setitem__(self, name, value):
value = ps
self.set(name, value)

def __getitem__(self, name):
return self.getScalar(name)

Copy link
Contributor

Choose a reason for hiding this comment

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

Please document what this does in a doc string, if you can figure out a sensible place to put it. I suspect for it to be easily understood it should be in the doc string for the class, but maybe a doc string here would work if sphinx is smart enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

daf_base still uses doxygen and I think the best place to document the dict-like behavior of PropertySet would be in the index.rst file once it's ported to sphinx. There doesn't seem to be a doxygen root page that I can augment.

tests/test_PropertyList.py Show resolved Hide resolved
timj added 2 commits May 28, 2019 09:09
get() now matches the dict.get API except that it always
calls getScalar internally whilst also providing a default
value.

The tests have been modified accordingly and the deprecation
message has been removed.
@timj timj merged commit b5ca14a into master May 28, 2019
@timj timj deleted the tickets/DM-19873 branch May 28, 2019 20:53
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.

None yet

2 participants