Skip to content

Fix for issue #5874 for fitscheck script not deleting CHECKSUM and DA… - #5875

Closed
mohanagr wants to merge 2 commits into
astropy:masterfrom
mohanagr:testFitsCheck
Closed

mohanagr wants to merge 2 commits into
astropy:masterfrom
mohanagr:testFitsCheck

Conversation

@mohanagr

Copy link
Copy Markdown
Contributor

Fix for issue #5874

I'll add the necessary tests for fitscheck script here.


# Checksums are not checked on invalid HDU types
if checksum and checksum != 'remove' and isinstance(hdu, _ValidHDU):
if isinstance(hdu, _ValidHDU):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That doesn't seem right, why check the checksum if the user doesn't want that?

@mohanagr mohanagr Mar 15, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But shouldn't it be fixed in the script then?

@mohanagr mohanagr Mar 15, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@mohanagr mohanagr Mar 15, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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=True it will proceed with verification and correction if possible,
  • if checksum='remove' it will remove the keywords when writing the changes (via writeto)
  • if checksum=False I understand that it should not proceed with verification, but does that mean _checksum property 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

@MSeifert04 MSeifert04 Mar 14, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that test doesn't make sense (yet) 😄

Note that python files need an empty newline at the end of each file

@bsipocz

bsipocz commented Sep 25, 2017

Copy link
Copy Markdown
Member

#6571 replaced this, so closing now.

@bsipocz bsipocz closed this Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants