Repository navigation
Conversation
… and DATASUM kwrds
|
|
||
| # Checksums are not checked on invalid HDU types | ||
| if checksum and checksum != 'remove' and isinstance(hdu, _ValidHDU): | ||
| if isinstance(hdu, _ValidHDU): |
There was a problem hiding this comment.
That doesn't seem right, why check the checksum if the user doesn't want that?
There was a problem hiding this comment.
@MSeifert04 Yes yes, I'll add a null check. Although all I want is _verify_checksum_datasum to be called even if checksum is False because tha is the only function that sets self._checksum (set self._checksum to None) And if that's not set one will get AttributeError every time -k none option is used. Well may be I should modify that to make it little more logical!
There was a problem hiding this comment.
(https://github.com/astropy/astropy/blob/master/astropy/io/fits/scripts/fitscheck.py#L143)
The script is going to access hdu._checksum anyways.
There was a problem hiding this comment.
But shouldn't it be fixed in the script then?
There was a problem hiding this comment.
Not really. IMO When we use fits.open with checksum=False it basically doesn't touch whatever CHECKSUM/DATASUM there is. So if one has used False, he doesn't care about CHECKSUM keys but that doesn't mean that self._checksum shouldn't be set. It should be set to whatever value of CHECKSUM there is (None otherwise).
There was a problem hiding this comment.
I'm confused, why does it need to be set if one doesn't want to compare it to the computed checksum? It's a private attribute so anything except the class or subclasses shouldn't really be using it. I mean the script is basically just asking if there's a CHECKSUM in the header, right?
There was a problem hiding this comment.
@MSeifert04 Yes. Exactly that's what I thought, self._checksum should really be used as such. Defeats the purpose. But I said all that considering that I don't have to make any changes to the script itself.
This is what a note in the code says and the reason I didn't modify the script :
# NOTE: private data members _checksum and _datasum are
# used by the utility script "fitscheck" to detect missing
# checksums.
There was a problem hiding this comment.
All I was saying is:
Consider a FITS file in which hdu's have a checksum. In such a case if I open it with
checksum=Trueit will proceed with verification and correction if possible,- if
checksum='remove'it will remove the keywords when writing the changes (viawriteto) - if
checksum=FalseI understand that it should not proceed with verification, but does that mean_checksumproperty should remain unset (even if keywords were present).
| hdulist[0].header['DATASUM'] | ||
|
|
||
| def test_check_compliance_only(self, capsys, monkeypatch): | ||
| pass No newline at end of file |
There was a problem hiding this comment.
that test doesn't make sense (yet) 😄
Note that python files need an empty newline at the end of each file
|
#6571 replaced this, so closing now. |
Fix for issue #5874
I'll add the necessary tests for
fitscheckscript here.