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

Set units in QTable for multiple columns #13010

Open
LibrEars opened this issue Mar 29, 2022 · 2 comments
Open

Set units in QTable for multiple columns #13010

LibrEars opened this issue Mar 29, 2022 · 2 comments

Comments

@LibrEars
Copy link

Description

I would like to set the unit for multiple columns of a QTable

Expected behavior

Set the unit of multiple columns in one command:

table = QTable(names=["a","b","c","d","e"])

table["a"].unit = u.A        # works like expected
table["b", "c", "d"].unit = u.mV # does not work like expected

table[table.columns[1:3]].unit = u.mV # slicing would be nice but does not work eather

Actual behavior

table["b","c","d"] returns a copy of the table and not a view. Therefor the changing the units has no effect.

Workaround if someone stumbles about this:

Use a loop to set the unit for each column individually

for col in table.columns[1:3]:
    table[col].unit = u.mV  

Suggestion

If returning a view is not desirable, maybe an attribute table.units could be introduced, exposing some way to manipulate multiple units

table.units[1:3] = u.mV

# or maybe
table.units[table.columns[1:3]] = u.mV

System Details

Linux-5.10.0-12-amd64...
Python 3.9.2
Numpy 1.22.1
pyerfa 2.0.0.1
astropy 5.0.1
Scipy 1.7.3
Matplotlib 3.5.1

@LibrEars LibrEars added the Bug label Mar 29, 2022
@github-actions
Copy link

Welcome to Astropy 👋 and thank you for your first issue!

A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details.

GitHub issues in the Astropy repository are used to track bug reports and feature requests; If your issue poses a question about how to use Astropy, please instead raise your question in the Astropy Discourse user forum and close this issue.

If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org.

@pllim pllim added the table label Mar 29, 2022
@neutrinoceros
Copy link
Contributor

@taldcroft it looks to me that nothing is actually broken here and there's even a mention of a supported way of achieving the desired result so I would recommend changing the "bug" label for a "question" and close the issue as "won't fix".

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

No branches or pull requests

3 participants