You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Table caches column print formats for too long #5800
If a format for a column is given and a table is printed, the corresponding format function is cached. Unfortuately, this means it will also get used on another table holding a column with the same name:
from astropy.table import Table, QTable, Column
t = Table([Column([1.,2.], unit='m', name='a')])
t['a'].format = '%f'
t
# <Table length=2>
# a
# m
# float64
# -------
# 1.0
# 2.0
QTable(t)
# ... ---------------------------------------------------------------------------
# UnitConversionError
Not quite sure whether it would be best to clear the cache in various places or to index columns by something else than their name. It is not quite obvious to me speed is an issue here, since printing is so slow anyway.
At least this patch fixes your particular problem. I'm not too inclined to remove the caching unless we have a reliable way to prove that this will not slow things down.
Yes, that was my first thought too, and I think we should go for that at least for now (I ran into it in writing the [Q]Table vstack-ing tests, where I run the same tests for both, and then the second one mysteriously failed).
An alternative (but could be done later), would be to store the format function on info -- this has the advantage that it could be created upon setting info.format, i.e., one would get instant validation.
One issue with instant validation is that you can't always do it because you might not actually have data in the column at the time of defining the format.
True -- since you now have a simple fix in the works, which will close this issue, I created a new one as a reminder that perhaps we may want to rethink how this is implemented: #5804.
Activity
taldcroft commentedon Feb 13, 2017
Caching by the object ID seems like it might a fair bit more reliable?
At least this patch fixes your particular problem. I'm not too inclined to remove the caching unless we have a reliable way to prove that this will not slow things down.
mhvk commentedon Feb 13, 2017
Yes, that was my first thought too, and I think we should go for that at least for now (I ran into it in writing the
[Q]Tablevstack-ing tests, where I run the same tests for both, and then the second one mysteriously failed).An alternative (but could be done later), would be to store the format function on
info-- this has the advantage that it could be created upon settinginfo.format, i.e., one would get instant validation.taldcroft commentedon Feb 13, 2017
See #5803 for the easier solution.
One issue with instant validation is that you can't always do it because you might not actually have data in the column at the time of defining the format.
mhvk commentedon Feb 13, 2017
True -- since you now have a simple fix in the works, which will close this issue, I created a new one as a reminder that perhaps we may want to rethink how this is implemented: #5804.