-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add support for fill_values functionality with ascii html #5379
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
Conversation
7bbc8b7 to
8010112
Compare
|
@tylfin - I haven't had a chance to look through this line by line, but overall it looks much better and seems to be on track! |
astropy/io/ascii/html.py
Outdated
| return None | ||
| return last_index + 1 | ||
|
|
||
| def set_fill_values(self, header, cols, fill_values): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might not need this new method as some of the things being set are probably redundant. At the place where this gets called, self.data is the same as self here. So for instance the self.data object already has a copy of header from __init__. So just try moving these statements inline and then remove one-by-one until things break.
The issue is just that all this code is really intricate and intertwined already (sorry), so working hard to minimize complexity is important.
astropy/io/ascii/html.py
Outdated
| cols = list(six.itervalues(table.columns)) | ||
|
|
||
| # Set fill_vals on the columns for replacement | ||
| HTML.data_class().set_fill_values(self.header, cols, self.data.fill_values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to use self.data instead of HTML.data_class().
astropy/io/ascii/tests/test_html.py
Outdated
| </tr>""" | ||
| assert expected in out.getvalue() | ||
|
|
||
| def test_write_table_html(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also test with a table that has masked values where you set fill_values to [(ascii.masked, 'TEST')] and confirm that the masked table entries are indeed TEST.
astropy/io/ascii/tests/test_html.py
Outdated
| </tr>""" | ||
| assert expected in out.getvalue() | ||
|
|
||
| def test_write_table_html(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test with a table that has a multi-dimensional column, i.e. each row is a 1-d array.
|
@taldcroft I think I've addressed all the comments you made, tell me if there is anything else! |
|
@tylfin - this is overall much better again, but I think there is a problem in the masked element handling. Can you add a test along the lines of the example below to make sure it passes? |
Test for fill_values ascii html format issue Test for fill_values ascii html format with optional columns Test for fill_values ascii html format with masked values Test for fill_values ascii html format with multidimensional columns Test for fill_values ascii html format with masked values on multidimensional columns Add fill_values method on HTML that yields either the values themselves, the filled values, or the masked values
|
@taldcroft Should be taken care of now! Refactored the masked values logic & added the example above as a test. |
|
@tylfin - looks good, now we just need an update to |
|
Thanks @tylfin !! |
Add support for fill_values functionality with ascii html
|
Unfortunately this PR as-is doesn't seem to be backport-able to 1.0.x, as it uses features that seem to be missing in 1.0.x. A PR directly to the 1.0.x branch addressing this is welcome, though! |
|
Hello.
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/io/ascii/ui.pyc in write(table, output, format, Writer, fast_writer, **kwargs) /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/io/ascii/html.pyc in write(self, table) /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/io/ascii/html.pyc in fill_values(self, col, col_str_iters) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() I am not familiar enough with python and its coding to find a robust solution. I am sorry |
Fixes #5354