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-14842: Fix deprecation warnings from PropertyList/Set.get #37

Merged
merged 1 commit into from Jun 22, 2018

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented Jun 20, 2018

In updating code to use PropertySet.getArray or getScalar,
instead of get, I realized that the only reasonable thing
getArray can do with items that are neither numeric or scalar
(e.g. PropertySet or PropertyList) is return them, preferably
as a scalar. This allows one to iterate over all items and safely
get everything. It also makes getArray work like get and
getScalar for such items, which is a simple mental model.

@@ -62,28 +62,17 @@ def _propertyContainerGet(container, name, returnStyle):
name : ``str``
Name of item
returnStyle : ``ReturnStyle``
Control whether data is returned as an array or scalar:
Control whether numeric or string data is returned as an array

Choose a reason for hiding this comment

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

I got myself confused when reconciling the docs and commit message. I understand:
(1) getArray(nameofAPropertyList) should return a scalar that one can iterate over.
(2) If ReturnStyle.SCALAR, then it returns the last value?

Does this mean the scalar reference in #1 is a different concept than #2? Because I would naively think: the property list is being returned as a scalar, which means I get the last value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of iterating (in my commit message) is that if you want to iterate over all items in a PropertySet or PropertyList then getArray is the approved way to do it because it returns all numeric or string data (instead of ignoring all but the last value, like getScalar. However, before this commit getArray would raise an exception for items that were neither numeric nor strings, which meant iterating over all items was a very messy business (you had to determine the data type first, then call getArray if numeric or string). Now you can just call getArray on any item and get something sensible back -- something that contains all known information about that item.

In updating code to use `PropertySet.getArray` or `getScalar`,
instead of `get`, I realized that the best thing `getArray` can do
with items that are neither numeric or scalar (e.g. `PropertySet`
or `PropertyList`) is return them, preferably as a scalar.

This allows one to retrieve all known information about any
item in a container by calling `getArray`.
Formerly this was difficult: you would have to first determine
the data type (e.g. by calling `getScalar`) then call `getArray`
if the type was numeric or string.
@r-owen r-owen merged commit aa1012f into master Jun 22, 2018
@ktlim ktlim deleted the tickets/DM-14842 branch August 25, 2018 06:44
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