Repository navigation
Fix use of memmap with Table.read and add option to deactivate the masking of invalid values - #12544
Conversation
|
There is already conflict. Is your branch very old? |
|
It's from 2 weeks ago, but there was the |
|
My sense is that if the user passes in But I'm also wondering a bit what changed in #11222 that actually broke the previous behaviour - it looks like also before all the data was loaded if there is any column with |
|
Having to use The TNULL case ( |
|
OK, reading your comment, I now definitely agree with explicit being better! In principle, one could still let the default of whether or not to mask depend on But I'm still confused what in #11222 actually caused a change in behaviour (at least for |
|
@mhvk - Updating this PR since the issue was also raised in #12981.
As we discussed above, before #11222 |
|
@saimn - I'm not a FITS expert but the new arg and code certainly do stop that masking code from executing. If this will solve the issue of memmap not working then I'm willing to sign off on this API change. The PR needs work, docstring update, narrative docs that indicate this use case, some functional testing or unit tests to prove that the change does indeed fix the memmap issue, etc. (Also for the record update the PR title and description to be more like the PR that solves the problem instead of an issue reporting it.) Thanks for working on this, it would be good to get for this release since this seems like a pretty bad issue. |
| def read_table_fits(input, hdu=None, astropy_native=False, memmap=False, | ||
| character_as_bytes=True, unit_parse_strict='warn'): | ||
| character_as_bytes=True, unit_parse_strict='warn', | ||
| mask_invalid=True): |
There was a problem hiding this comment.
Is it worth considering making mask_invalid default to False if memmap is True?
There was a problem hiding this comment.
I'm not sure, it can be unexpected to get an unmasked table when using memmap=True. Maybe a warning if memmap=True and mask_invalid=True to explain the user why they also need to set mask_invalid=False ?
There was a problem hiding this comment.
Both seem to have advantages: I like the clarity of the warning in that users do not get unexpected data, but worry slightly about read_table_fits being done well inside code where a user may not have access.
I guess eventually we could have a memmap='if_possible'...
I do worry a bit how this function is getting more and more arguments about arguably small differences in how to handle specific items. I wonder if this is the best way to handle them. But that's for another discussion...
There was a problem hiding this comment.
The interest of using memmap here is limited to quite specific cases (reading a subset of the rows, #9404, #8573 (comment)), so I don't think a warning would annoy a lot of people. But it's also true if we set mask_invalid=False when using memmap, so maybe it's a good option as well.
There was a problem hiding this comment.
I'll let you make the call -- I cannot decide even which option I think is better...
There was a problem hiding this comment.
Ok, I went for the first option, setting mask_invalid=False when using memmap, and added some explanations in the docstring.
I added some docs and tests however testing that memmap is actually working is not so easy (it's not tested currently, some tests are testing
Good point, done. |
|
@taldcroft @mhvk - Can you have another look? I think I addressed the various points. |
mhvk
left a comment
There was a problem hiding this comment.
Looks good! Only a few textual comments (plus a nitpick)
| mask_invalid : bool, optional | ||
| By default the code masks NaNs in float columns and empty strings in | ||
| string columns. Set this parameter to `False` to avoid the performance | ||
| penalty of doing this masking step. It's also needing when using |
There was a problem hiding this comment.
Maybe replace last sentence by "The flag is ignored when using memmap=True..."
|
|
||
| else: | ||
|
|
||
| if memmap and mask_invalid: |
There was a problem hiding this comment.
Nitpick: Can just be if memmap:
| @@ -0,0 +1,3 @@ | |||
| Add a ``mask_invalid`` option to ``Table.read`` to deactivate the masking of | |||
There was a problem hiding this comment.
Maybe "... to allow deactivating ..." (since by default the option activates it)
|
@mhvk - Thanks, done. |
|
@meeseeksdev backport to v5.0.x |
This comment was marked as resolved.
This comment was marked as resolved.
|
@saimn , if you really wants this backported, you have to manually do it. If not, please change the milestone. Thanks! |
…option to deactivate the masking of invalid values
…option to deactivate the masking of invalid values
Backport PR #12544 on branch v5.0.x (Fix use of memmap with Table.read and add option to deactivate the masking of invalid values)
Pin 3a0cd2d8cd7b459cdc1e1b97a14f3040ccc1fffc and its regression selectors for reproducible runs. Source: astropy/astropy#12544
Since #11222 (v4.3) using
memmapwithTable.readis no more possible since the data is loaded to look for NaNs in float columns and empty strings in string columns. I think adding an option to avoid those checks would be useful, though I'm not sure what should be the default value.Trueis best for compatibility with v4.3+ and people may expect Astropy to mask by default.Falseis best for memory usage and performance on big tables.Update: the PR adds a
mask_invalidoption and deactivates the masking when using memmap, also fix #12981 which is asking for a similar option.Description
This pull request is to address ...
Fixes #
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.