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
Allow specifying column names in Table.as_array() #8532
Conversation
3634ba8
to
6c6817d
Compare
Codecov Report
@@ Coverage Diff @@
## master #8532 +/- ##
==========================================
- Coverage 86.81% 86.81% -0.01%
==========================================
Files 386 386
Lines 58164 58169 +5
Branches 1060 1060
==========================================
+ Hits 50495 50497 +2
- Misses 7054 7057 +3
Partials 615 615
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #8532 +/- ##
==========================================
- Coverage 86.81% 86.81% -0.01%
==========================================
Files 386 386
Lines 58162 58164 +2
Branches 1060 1060
==========================================
+ Hits 50493 50494 +1
- Misses 7054 7055 +1
Partials 615 615
Continue to review full report at Codecov.
|
02d864c
to
5a2f9eb
Compare
@bsipocz I think Tarvis-ci failure is not related to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few changes needed but this is mostly there.
@taldcroft Thanks for reviewing changes performed as suggested |
7e61d2e
to
9d0b070
Compare
astropy/table/table.py
Outdated
@@ -261,7 +265,11 @@ def as_array(self, keep_byteorder=False): | |||
|
|||
dtype = [] | |||
|
|||
cols = self.columns.values() | |||
if names != None: | |||
cols = self[names].columns.values() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himanshupathak21061998 - sorry, I made this comment a few days ago but must not have actually put it it in the review... So one more fix, related to performance. Using self[names]
is simple and clean, but it is inefficient since this makes a temporary full copy of all the data for names
and creates a new table just to get out the subset of columns. Instead:
cols = self.columns.values()
if names != None:
cols = [col for col in cols if col.info.name in names]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taldcroft Thanks for reviewing suggested changes have been performed. Yes I didn't notice this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @himanshupathak21061998, thanks!!
Thanks for merging |
#8529 @taldcroft Please have a look at this PR.