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
Just so we do not loose track of a possibility discussed in #5800 for how to deal with formats for table columns. Currently, one can set <col>.info.format and this gets used in printing the table, by creating a custom format function that uses the format given (which can be old or new or shortened style). The printing machinery caches these functions as they are relatively expensive to create and one doesn't want to recreate them for every element of a column. It would seem perhaps more logical to move this logic to the column itself, i.e., that info stores also the formatting function. In principle, this function could even be created when one sets format, though this would have to work around the case where the column does not yet have any data associated with it.
Adding the bug label since the current implementation causes problems (#6703). In #6703, @larrybradley noted that if one were to create the format function only at the point one was actually trying to format the column, there would not ever be an issue with there being no data.
Overall, I would envisage an implementation where there is a some function (perhaps just __format__) which creates and caches a print function when called (except when first element is masked/NaN), and the cache would get deleted whenever col.info.format is set.
@neutrinoceros - you are right, this was solved in #6714, and that in fact used the suggestion given here to store the format function on col.info. So, this one can be closed. Thanks!
Activity
mhvk commentedon Oct 10, 2017
Adding the
buglabel since the current implementation causes problems (#6703). In #6703, @larrybradley noted that if one were to create the format function only at the point one was actually trying to format the column, there would not ever be an issue with there being no data.Overall, I would envisage an implementation where there is a some function (perhaps just
__format__) which creates and caches a print function when called (except when first element is masked/NaN), and the cache would get deleted whenevercol.info.formatis set.neutrinoceros commentedon Dec 6, 2023
#6703 was closed in astropy 3.0, do you think the bug label is still relevant @mhvk ?
mhvk commentedon Dec 6, 2023
@neutrinoceros - you are right, this was solved in #6714, and that in fact used the suggestion given here to store the format function on
col.info. So, this one can be closed. Thanks!