Closed zackw closed 1 month ago
This seems correct to me. Unless @m-stclair or @Sierra-MC see issues, let's do it.
I need to think about it more and discuss. The existence of the keys()
and __getitem__()
methods are not intended to imply that Data
is a Mapping
or even a Collection
, and it is not intuitive to me that Data.__contains__()
should produce this result.
I'm even questioning why Data.__iter__()
exists, honestly, although it's probably too late to remove it.
after discussion we have decided:
Data
will be given a __contains__
method aliasing data.keys().__contains__
Data.__iter__()
will be deprecated after the introduction of a DeprecationWarning
and some months. keeping issue open until these are released.Closed with release 1.2.0
pdr.Data
objects act like dicts to some extent: they have a keys() method [albeit not values() or items()] that returns a list of the data objects they contain, and they support using[]
to access any of those data objects by name. Logically, therefore, you ought to be able to use'name' in data_object
as well, but this throws a strange exception:The strange exception is because, when object
b
does not implement a__contains__
method,a in b
falls back to something not entirely unlikeand iteration over a pdr.Data object iterates over the values of the contained data objects, not their names, so in the above example it tries to compare the string 'HEADER' to the DataFrame generated by loading the TABLE object.
I imagine we are stuck with that for backward compatility's sake, but we can still implement
__contains__
to make'name' in data_object
work as expected.