Skip to content
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

Bug when trying to set the unit on a TimeSeries column #8642

Closed
astrofrog opened this issue Apr 26, 2019 · 1 comment · Fixed by #8902
Closed

Bug when trying to set the unit on a TimeSeries column #8642

astrofrog opened this issue Apr 26, 2019 · 1 comment · Fixed by #8902

Comments

@astrofrog
Copy link
Member

When trying to set the unit on a time series column, I am running into an error:

>>> from astropy import units as u
>>> from astropy.timeseries import TimeSeries
>>> ts1 = TimeSeries(time_start='2016-03-22T12:30:31', time_delta=3 * u.s, n_samples=5)
>>> ts1['flux'] = [1,2,3,4,5]
>>> ts1['flux'].unit = 's'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-1ddfdfcdb27c> in <module>
      3 ts1 = TimeSeries(time_start='2016-03-22T12:30:31', time_delta=3 * u.s, n_samples=5)
      4 ts1['flux'] = [1,2,3,4,5]
----> 5 ts1['flux'].unit = 's'

~/Code/astropy/astropy/table/column.py in __setattr__(self, item, value)
    853             else:
    854                 if converted is not self:
--> 855                     self.parent_table.replace_column(self.name, converted)
    856 
    857     def _base_repr_(self, html=False):

~/Code/astropy/astropy/table/table.py in replace_column(self, name, col)
   1920             raise ValueError('cannot replace a table index column')
   1921 
-> 1922         t = self.__class__([col], names=[name])
   1923         cols = OrderedDict(self.columns)
   1924         cols[name] = t[name]

~/Code/astropy/astropy/timeseries/sampled.py in __init__(self, data, time, time_start, time_delta, n_samples, **kwargs)
     89 
     90         if time is None and time_start is None:
---> 91             raise TypeError("Either 'time' or 'time_start' should be specified")
     92         elif time is not None and time_start is not None:
     93             raise TypeError("Cannot specify both 'time' and 'time_start'")

TypeError: Either 'time' or 'time_start' should be specified

I haven't investigated this yet, but at first glance I'm surprised that simply setting the unit on a column causes a new TimeSeries to be instantiated.

@pllim
Copy link
Member

pllim commented Apr 26, 2019

Maintainer's note: timeseries was added in #8540 , so this fix only needs to be backported to 3.2 series and no earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants