Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-6718

afw table and record should have useful str() and repr()

    XMLWordPrintable

    Details

    • Story Points:
      2
    • Sprint:
      Alert Production S17 - 5, Alert Production S17 - 6, Alert Production F17 - 7
    • Team:
      Alert Production

      Description

      To see the contents of an afw table in python, you have to do something like

      catalog[0].extract("*")

      which is totally not discoverable and returns a dict which doesn't print well. Much more useful would be for str() on a record to produce a pretty-printed list of the contents, and str() on a table to produce some nicely formatted summary (like a numpy recarray does, only printing a few things separated "..." for large tables).

      I'm not sure what the best repr() output would be (certainly for a Record it should be a full dump of the contents), but currently table.repr()==table.str(), which is equally unhelpful.

      Maybe this will come "for free" when we get astropy.table views, but it makes exploring the contents of a table a pain right now.

        Attachments

          Issue Links

            Activity

            Hide
            Parejkoj John Parejko added a comment -

            Doing this as part of today's pair coding exercise.

            Show
            Parejkoj John Parejko added a comment - Doing this as part of today's pair coding exercise.
            Hide
            Parejkoj John Parejko added a comment -

            Thanks to Krzysztof Findeisen for pair coding this with me. It's not a perfect implementation, but I think it's a huge improvement over the previous.

            Nate Lust, can you please review this? I'm not sure how well it conforms to RFC-298, but I'm not sure what would be appropriate for that in the context of a catalog anyway.

            Show
            Parejkoj John Parejko added a comment - Thanks to Krzysztof Findeisen for pair coding this with me. It's not a perfect implementation, but I think it's a huge improvement over the previous. Nate Lust , can you please review this? I'm not sure how well it conforms to RFC-298 , but I'm not sure what would be appropriate for that in the context of a catalog anyway.
            Hide
            ctslater Colin Slater added a comment -

            The other suggestion I was going to make before standup intervened is that it would be particularly useful if tables printed nicely in jupyter notebooks. I think that might be as easy as passing _repr_html_ on to astropy as well.

            Show
            ctslater Colin Slater added a comment - The other suggestion I was going to make before standup intervened is that it would be particularly useful if tables printed nicely in jupyter notebooks. I think that might be as easy as passing _repr_html_ on to astropy as well.
            Hide
            nlust Nate Lust added a comment -

            two minor points in the pr. Also, is it worth considering Colin's question on this ticket?

            Show
            nlust Nate Lust added a comment - two minor points in the pr. Also, is it worth considering Colin's question on this ticket?
            Hide
            Parejkoj John Parejko added a comment -

            Thanks for the review, and the offline discussion. I responded to your question about non-contiguous tables in the PR, but just to summarize here: we're probably better off not special casing lots of code to deal with our non-contiguous tables, but rather fixing those to behave better. So, they'll continue to be annoying to work with until we do that, at the savings of not having lots of extra code in the stack.

            And I did add repr_html, so catalogs will automagically pretty-print in jupyter notebooks.

            Merged and done.

            Show
            Parejkoj John Parejko added a comment - Thanks for the review, and the offline discussion. I responded to your question about non-contiguous tables in the PR, but just to summarize here: we're probably better off not special casing lots of code to deal with our non-contiguous tables, but rather fixing those to behave better. So, they'll continue to be annoying to work with until we do that, at the savings of not having lots of extra code in the stack. And I did add repr_html , so catalogs will automagically pretty-print in jupyter notebooks. Merged and done.

              People

              Assignee:
              Parejkoj John Parejko
              Reporter:
              Parejkoj John Parejko
              Reviewers:
              Nate Lust
              Watchers:
              Colin Slater, Jim Bosch, John Parejko, John Swinbank, Nate Lust, Russell Owen, Simon Krughoff
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins Builds

                  No builds found.