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

Fix #101 to support Julia 0.6, 0.7 and 1.0 #104

Merged
merged 10 commits into from Sep 7, 2018
Merged

Fix #101 to support Julia 0.6, 0.7 and 1.0 #104

merged 10 commits into from Sep 7, 2018

Conversation

emmt
Copy link
Member

@emmt emmt commented Sep 6, 2018

This PR is both a review and a fix of #101 to extend FITSIO support to all Julia versions ≥ 0.6

The fixes are summarized in the commit comments. The proposed PR passes all the tests with Julia versions 0.6.4, 0.7.0 and 1.0.0.

For the review part, I fully agree with most of the changes done in #101. In fact, they are quite similar to my changes in #103, thus this new PR is a candidate for replacing #101 and #103. In #101 and #103. As discussed in #101 and #103, the most significant changes concern the try_parse_hdrval methods:

  • Methods try_parse_hdrval(T,s) (with a type and a string arguments) used to return a Nullable{T} result and now returns either a value of type T or nothing if unsuccessful. This follows the behavior of the tryparse methods in latest Julia versions.

  • Method try_parse_hdrval(s) (with a single string argument) was only called by parse_header_val. It has been deleted (in this PR) and its code moved into method parse_header_val.

Note that methods try_parse_hdrval can be assumed to be private as they are not documented in FITSIO doc. and are only called in the file header.jl. These changes should not affect the end users.

Future improvements

  • Methods fits_try_read_keys, fits_try_read_extname and fits_try_read_extver may be assumed to be public. Their API shall be clearly documented, defined and fixed. They should be directly tested in runtests.jl.

  • The type of the value of a FITS keyword can be inferred from the first non-space character (a quote '\'' must be a string, a letter 'T' or 'F' must be a boolean, only spaces must be an empty value and anything else can only be an integer or a floating-point). This fact can be used to speed-up the parsing of FITS keywords in parse_header_val.

  • According to FITS standard Section 5.4.2.6 "Extension Keywords" (https://archive.stsci.edu/fits/fits_standard), EXTNAME shall be a string while EXTVER shall be an integer. Both should not appear in the primary header. This may be taken into account by methods fits_try_read_extname and fits_try_read_extver.

mweastwood and others added 8 commits July 5, 2018 10:25
We still get one deprecation warning for `Base.Libdl`, but these come from `BinaryProvider`.
Appart from trivial changes to avoid deprecation warnings (for things
allowed in 0.7 but forbidden in 1.0) and to maintain compatibility with
Julia 0.6, the main changes/fixes are:

* When closing a FITS file, set `f.ptr` to `C_NULL prior to checking
  whether there was an error.  This is to avoid trying to close
  more than once in case an error occurs.

* Fix FITS handle being used as an iterable (i.e., extend method `iterate`
  instead of methods `done`, `next` and `start`).

* Method `try_parse_hdrval(s)` (with a single string argument) is not used
  anywhere and has been deleted and its code moved into method
  `parse_header_val`.  Note that methods `try_parse_hdrval` can be assumed
  to be *private* as they are not documented in [FITSIO
  doc.](http://juliaastro.github.io/FITSIO.jl/latest/) and are only called
  in the file `header.jl`.
@giordano
Copy link
Member

giordano commented Sep 6, 2018

This is great! I hope I'll be able to have a look tonight.

@mweastwood
Copy link
Member

Thanks for picking up where I left off! This looks great.

Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@giordano
Copy link
Member

giordano commented Sep 7, 2018

Ok, I think we've waited enough considered that #101 has been open for some months now, I'm going to merge this. Thanks again @emmt and @mweastwood!

@giordano giordano merged commit 0ccb1a6 into JuliaAstro:master Sep 7, 2018
@giordano
Copy link
Member

giordano commented Sep 7, 2018

@emmt You've outlined some good future improvements: please put them in a new issue, so they won't be lost here 😉

@emmt
Copy link
Member Author

emmt commented Sep 9, 2018

Yes I will do that. Thanks!

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.

None yet

3 participants