_BaseDiff evaluates to incorrect boolean
See original GitHub issueAstropy 4.2.1
Consider the following:
>>> h1 = fits.Header()
>>> if fits.HeaderDiff(h1, h1): print('These are the same')
...
>>>
Nothing is printed.
The culprit is in _BaseDiff.__bool__
:
https://github.com/astropy/astropy/blob/e183e398d8bdbbe5c7ccec7a793afed2ecdac4e1/astropy/io/fits/diff.py#L74-L80
Despite the docstring (and other documentation) suggesting that identical objects evaluate to True
the return value here is not self.identical
.
I tried making a quick fix to this but it broke 19 tests in io.fits
so I figured I’d better leave this to the professionals 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
What evaluates to True/False in R? - boolean - Stack Overflow
Having 1==TRUE evaluate to TRUE as a special case along with 0 for FALSE is a general rule in many programming languages, not...
Read more >Conditionals with if/else & Booleans | AP CSP (article)
The condition is a Boolean expression: an expression that evaluates to either true or false . Boolean values are another type of data...
Read more >true and false operators - treat objects as Boolean values
The false operator returns the bool value true to indicate that its operand is definitely false. The true and false operators aren't guaranteed ......
Read more >Boolean - JavaScript - MDN Web Docs
The Boolean object represents a truth value: true or false.
Read more >Boolean Data Type
Logical operators combine boolean values and evaluate to a boolean result. Operator. Name. Example. Result ! Logical. NOT !a true if a is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep! My plan is to work on this and #11770. Hopefully somewhat soon. If someone wants to assign this issue to me I’m fine with it!
Maybe the docstring is wrong. I interpret that when
bool(diff)
isTrue
, there is a difference, andFalse
when there is no difference (i.e., things are the same). @saimn or @embray , what do you think?