Skip to content

Conversation

@davidhassell
Copy link
Collaborator

Fixes #281

@davidhassell
Copy link
Collaborator Author

Note to selves: think about this as part of the dask work.

@davidhassell davidhassell changed the title Allo elemntwise comparisons with None Allo element-wise comparisons with None Nov 25, 2021
Copy link
Member

@sadielbartholomew sadielbartholomew left a comment

Choose a reason for hiding this comment

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

All good, assuming the desired behaviour for the specific case Bryan raised (as I am guessing from the thread on the corresponding Issue), along with the obvious general behaviour, is that:

In any case, I'm glad you're putting in a PR so the right error is raised rather than a stackdump.

namely that we return the same error as numpy (#281 (comment)), which is indeed implemented:

>>> d = cf.Data(np.array([1, 2, 3]))
>>> if d != None:
...     print("nope")
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sadie/cf-python/cf/data/data.py", line 1544, in __bool__
    raise ValueError(
ValueError: The truth value of Data with more than one element is ambiguous. Use d.any() or d.all()

@sadielbartholomew
Copy link
Member

sadielbartholomew commented Nov 25, 2021

The linting workflow is failing on some spurious whitespace, which I will deal with after so we can merge this as-is. There is a 3.6 workflow running, too, when it shouldn't as we dropped 3.6, hence the failure of it, so I'll deal with that.

@sadielbartholomew sadielbartholomew merged commit f2ba07a into NCAS-CMS:master Nov 25, 2021
@davidhassell davidhassell changed the title Allo element-wise comparisons with None Allow element-wise comparisons with None Jan 4, 2022
@davidhassell davidhassell added this to the 3.12.0 milestone Jan 4, 2022
@davidhassell davidhassell deleted the issue-281 branch November 15, 2022 09:12
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.

attempting to compare a cf field with None returns an error

2 participants