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

containment checking on DataQuery fails with KeyError #2496

Open
gerritholl opened this issue May 25, 2023 · 1 comment
Open

containment checking on DataQuery fails with KeyError #2496

gerritholl opened this issue May 25, 2023 · 1 comment
Assignees
Labels

Comments

@gerritholl
Copy link
Collaborator

Describe the bug

Checking for containment in a DataQuery fails with KeyError.

To Reproduce

from satpy import DataQuery
dq = DataQuery(name="pytroll")
"name" in dq

Expected behavior

I expect either a TypeError (in case containment checking is not supported) or the answer (True/False).

Actual results

Traceback (most recent call last):
  File "/data/gholl/checkouts/protocode/mwe/dq-keyerror.py", line 3, in <module>
    "name" in dq
  File "/data/gholl/checkouts/satpy/satpy/dataset/dataid.py", line 512, in __getitem__
    return self._dict[key]
           ~~~~~~~~~~^^^^^
KeyError: 0

I don't understand where the 0 is coming from.

Environment Info:

  • Satpy Version: main

Additional context

I want to test if a DataQuery contains a time parameter in my attempt of implementing temporal composites at #2495.

Workaround:

"name" in dq.to_dict()
@djhoese
Copy link
Member

djhoese commented May 25, 2023

Yeah I guess it would make sense to have this functionality available and treat it as a "frozen dict".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants