Skip to content

Address issue #8995 by ignoring BINARY2 mask bits for string values. - #9057

Merged
pllim merged 6 commits into
astropy:masterfrom
tomdonaldson:masked-column-writing
Oct 24, 2019
Merged

pllim merged 6 commits into
astropy:masterfrom
tomdonaldson:masked-column-writing

Conversation

@tomdonaldson

Copy link
Copy Markdown
Contributor

VOTables with BINARY2 serialization can mark values as null with a bit at the beginning of the data row. On read, each of these marked values was being stored as a numpy.ma.core.MaskedConstant. That makes sense for numerical values, but much less so for string values. Those MaskedConstants for strings then caused problems on writing the table back out.

This fix changes the reader behavior to ignore the BINARY2 null bits for string values.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you! Need a rebase to get rid of some of the CI failures. Also, seems like test still needs some work? Please see comments.

Comment thread astropy/io/votable/tests/table_test.py Outdated
output = io.BytesIO()
astropy_table.write(output, format='votable')

# TODO - Construct test cases for unicodeChar strings and fixed length

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you have plans to follow up on this as part of this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought more about this and realize that the TODO is a larger homework assignment for me to better review/understand the existing test coverage. That is outside the scope of this PR, so I filed issue #9433 and removed the TODO comment.

# Ignore the mask for string columns (see issue 8995)
for i, f in enumerate(fields):
if f.datatype == 'char' or f.datatype == 'unicodeChar':
row_mask_data[i] = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you think we should emit warning when this happens?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. For the data consumer, they are getting the behavior they expect for empty strings (the behavior they would get from the other serializations), so a warning would be confusing.

For the data provider, there is a better case for the warning, since setting the null bit for the string may not have meant what they thought. But the spec is pretty vague on this, so I'd like to get more clarification before issuing a warning. Two other VOTable validators I tried do not issue a message of any kind for this case.

Comment thread astropy/io/votable/tree.py Resolved
@bsipocz

bsipocz commented Sep 27, 2019

Copy link
Copy Markdown
Member

Could you please rebase this? Also, let me know if there is a chance to finish it up in the next couple of days, otherwise feel free to remilestone to 4.0

@pllim

pllim commented Oct 1, 2019

Copy link
Copy Markdown
Member

@tomdonaldson , do you have time to wrap this up soon? Otherwise, we'll have to move the milestone.

@bsipocz bsipocz modified the milestones: v3.2.2, v4.0 Oct 5, 2019
@tomdonaldson
tomdonaldson force-pushed the masked-column-writing branch from e69f057 to 992cab1 Compare October 22, 2019 16:29
@tomdonaldson
tomdonaldson force-pushed the masked-column-writing branch from f94a896 to 23cb42b Compare October 22, 2019 19:41

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @tomdonaldson !

@pllim
pllim merged commit 9f96a60 into astropy:master Oct 24, 2019
@tomdonaldson
tomdonaldson deleted the masked-column-writing branch October 31, 2019 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants