Skip to content

Emit warning when assigned string value is truncated - #5624

Merged
taldcroft merged 3 commits into
astropy:masterfrom
taldcroft:table-string-warnings
Jan 14, 2017
Merged

taldcroft merged 3 commits into
astropy:masterfrom
taldcroft:table-string-warnings

Conversation

@taldcroft

Copy link
Copy Markdown
Member

This is a partial fix for #5551 so that a warning is emitted if a string value gets truncated when assigning in-place to a string column item.

There will be a performance penalty, but I think it is not too bad given that setitem is already using pure-Python code. Quick timeit testing showed that the difference is within the run-to-run uncertainty.

t = table.Table([['aa', 'bb']], names=['a'])

with catch_warnings() as w:
from inspect import currentframe, getframeinfo

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.

Not needed here. Move to the next catch_warnings block for readability

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.

OK, I have done this locally.

@taldcroft
taldcroft merged commit 3809bfa into astropy:master Jan 14, 2017
@taldcroft
taldcroft deleted the table-string-warnings branch January 14, 2017 15:55
@astrofrog

Copy link
Copy Markdown
Member

Great! This has been bugging me for a while 🎉

@taldcroft

Copy link
Copy Markdown
Member Author

#5700 has been bugging me for 4 years...

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