Skip to content

Support for masked tables with missing/invalid data - #451

Merged
taldcroft merged 54 commits into
astropy:masterfrom
taldcroft:table-masked
Nov 15, 2012
Merged

taldcroft merged 54 commits into
astropy:masterfrom
taldcroft:table-masked

Conversation

@taldcroft

Copy link
Copy Markdown
Member

This PR adds support in the table package for masked tables that contain missing or invalid data. This provides a wrapper around the numpy.ma masked array package and provides workarounds for a few features of that package.

Notes:

  • DO NOT MERGE just yet. Tests depend on pytest 2.3.3 (not yet released).
  • This PR is for evaluation of API, features, compatibility with other packages, etc.
  • Documentation is available in HTMLROOT/table/masking.html
  • @astrofrog contributed heavily to this PR.

@taldcroft

Copy link
Copy Markdown
Member Author

@eteq, @mdboom, @iguananaut - Tom R and I are hoping for some review of this PR when you get a chance. I've fully integrated this into io.ascii and it seems OK. Unfortunately there are conflicts merging into the current master that I haven't yet resolved.

Comment thread astropy/table/table.py Outdated

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.

Does this make Column never equal to a MaskedColumn -- and is that what we want? Maybe it should be isinstance(col, BaseColumn)? I could conceive of a case where we would want a Column to be equal to a MaskedColumn that happens to not have any elements masked out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a49832a.

@mdboom

mdboom commented Nov 8, 2012

Copy link
Copy Markdown
Contributor

Looks good. We'll probably want to rebase and test on top of master before merging, of course.

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - I tried to address some of @mdboom's issues - but I left the remaining ones for you to check.

@taldcroft

Copy link
Copy Markdown
Member Author

I've pushed a new branch table-masked-rebase in taldcroft/astropy that is rebased on the upstream master from this morning. This also includes a new commit to use parse_strict='silent' when initializing units in a Column. I haven't had a chance to address the remaining comments here, and I'm a little worried about losing them if I force-push the rebased version (maybe I'm being paranoid?). In any case I may not have much time to work on this over the next few days due to travel.

@taldcroft

Copy link
Copy Markdown
Member Author

BTW, thanks @jiffyclub for the pytest 2.3.3 work. The table tests with fixtures are working great now.

@astrofrog

Copy link
Copy Markdown
Member

I'd be fine with making masked read-only, and having set_masked().

@taldcroft

Copy link
Copy Markdown
Member Author

@astrofrog @eteq - I hope I have fixed the remaining numpy 1.4 errors (fingers crossed), they should be running now on jenkins.

I think of ValueError being "the value of the numpy version is wrong". I guess we could define a NumpyVersionError, but I think the audience for using this will be extremely small. By "using this", I mean writing code that catches the exception based on that name and then does something besides upgrading to a newer numpy.

The only other outstanding issue that I see (correct me if I'm wrong) is the documentation example of changing masking. I'm out of time this morning and will be busy during the day.

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - I'm pushing to my staging branch too, for the Windows tests (I think I'm the only user with a functional Windows staging branch)

@taldcroft

Copy link
Copy Markdown
Member Author

@astrofrog - any news on the Windows tests? Debian and MacOS look good now.

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - there were some issues with the running of the tests (it looks like shining panda initiated a build with the windows config, which causes all kinds of problems) but the builds that did run had no failures:

https://jenkins.shiningpanda.com/astropy/job/astropy-winxp32-staging-astrofrog/

I've forced a new build by adding an empty commit, so if we wait a couple of hours, we should know if it's all clear.

@taldcroft

Copy link
Copy Markdown
Member Author

I just noticed that t.set_masked(True) does not actually convert a table t to masked. I thought this was automatically happening, but it doesn't, so that needs to be fixed. And a test needs to be added of course.

@taldcroft

Copy link
Copy Markdown
Member Author

@astrofrog @eteq - Are you OK with making set_masked be hidden (_set_masked) and making the "one" way to convert a table to masked be:

t_masked = Table(t_unmasked, masked=True)

This simplifies code, and perhaps is more explicit.

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - what about adding a masked column to an unmasked table, which currently makes the table become masked - would you keep that? If so, then I'm fine with your suggestion of removing the attribute/method way of changing the masking.

@taldcroft

Copy link
Copy Markdown
Member Author

@astrofrog - yes, the current functionality for add_column and add_row would remain in place (since they work and are tested!). Both of those are more obviously changing the table data.

@astrofrog

Copy link
Copy Markdown
Member

Ok, then I agree, let's go with your suggestion!

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - I pushed to staging too for the Windows tests - results will appear here:

https://jenkins.shiningpanda.com/astropy/job/astropy-winxp32-staging-astrofrog/

in about an ~hour

@taldcroft

Copy link
Copy Markdown
Member Author

@astrofrog - good, thanks. Do you see anything else that needs to be done?

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - the only thing is adding an entry to the changelog, but other than that, it looks good to me!

@eteq

eteq commented Nov 15, 2012

Copy link
Copy Markdown
Member

@taldcroft - Yep, that solution seems fine to me - as you say, it's probably clearer that way.

As far as I'm concerned this is good to go, then - thanks!

@astrofrog

Copy link
Copy Markdown
Member

Looks like all the WIndows tests passed! This is good to go (apart from the changelog).

taldcroft added a commit that referenced this pull request Nov 15, 2012
Support for masked tables with missing/invalid data
@taldcroft
taldcroft merged commit e77c522 into astropy:master Nov 15, 2012
@taldcroft

Copy link
Copy Markdown
Member Author

Changelog updated and #451 merged.

@astrofrog

Copy link
Copy Markdown
Member

@taldcroft - FYI, numpy/numpy#2733 has been merged.

@astrofrog

Copy link
Copy Markdown
Member

For info, numpy/numpy#2703 has been merged, which should fix the issue with MaskedTable.view and filled values.

keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
Support for masked tables with missing/invalid data
astrofrog pushed a commit to astrofrog/astropy that referenced this pull request Jun 12, 2019
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
Accepting as affiliated package: BayesicFitting
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.

4 participants