{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/6098","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/6098/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/6098/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/6098/events","html_url":"https://github.com/astropy/astropy/issues/6098","id":229763304,"number":6098,"title":"AttributeError when setting QTable column unit","user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars0.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"labels":[{"id":229192,"url":"https://api.github.com/repos/astropy/astropy/labels/table","name":"table","color":"c7def8","default":false},{"id":12456977,"url":"https://api.github.com/repos/astropy/astropy/labels/units","name":"units","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-05-18T18:24:55Z","updated_at":"2017-05-18T21:07:27Z","closed_at":null,"body":"I'm trying to write some code that takes a Table or QTable and sets a new unit for a given column.\r\n\r\nTable and Column work as expected:\r\n```python\r\n>>> from astropy.table import Table, Column\r\n>>> t = Table(dict(a=[1, 2, 3]))\r\n>>> t['a'].unit = 's'\r\n>>> t['a'].info.unit = 's'\r\n```\r\n\r\nBut for QTable I'm sometimes getting AttributeError (and sometimes not):\r\n```python\r\n>>> from astropy.table import QTable, Column\r\n>>> t = QTable(dict(a=[1, 2, 3]))\r\n>>> t['a'].unit = 's'  # works\r\n>>> t['a'].info.unit = 's'\r\nAttributeError: can't set attribute\r\n```\r\nand then if I create a column by creating and assigning a `Column`, both going via `.info` or not fails (so somehow the `b` column is different from the `a` column in a subtle way?):\r\n```python\r\n>>> t['b'] = Column([4, 5, 6], unit='s')\r\n>>> t['b'].unit = 'm'\r\nAttributeError: can't set attribute\r\n>>> t['b'].info.unit = 'm'\r\nAttributeError: can't set attribute\r\n```\r\n@mhvk or @taldcroft) - Is this a bug or a feature?\r\n\r\n(this is on Astropy 2.0.dev18336)"},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/302541958","html_url":"https://github.com/astropy/astropy/issues/6098#issuecomment-302541958","issue_url":"https://api.github.com/repos/astropy/astropy/issues/6098","id":302541958,"user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars3.githubusercontent.com/u/2789820?v=3","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"created_at":"2017-05-18T21:07:27Z","updated_at":"2017-05-18T21:07:27Z","body":"@cdeil - before you decide, see my note on the interface being the tricky part: you can make that easy by using `Table`, but then everywhere else you're stuck with doing `.quantity`; if you forget it once on a column with angular degrees, and do `np.sin`, bad luck, wrong result. Or you can make the interface somewhat hacky -- and everywhere else things will work correctly, your users mistakes with units will get caught, etc.\r\n\r\np.s. But, no, `.quantity` does not make a copy."}}
{"actor":{"display_login":"mhvk"}}