Skip to content

Conversation

@mhvk
Copy link
Contributor

@mhvk mhvk commented Sep 19, 2014

In current master, comparisons of columns, like t['a'] > 0. correctly return an ndarray rather than a Column instance (see #1446 and #1685). However, this is not true for ufuncs like np.isfinite (see example below). This PR fixes that oversight, by checking at the end of __array_wrap__ whether the function that was used should return an array or a column.

At the same time, it includes a small rewrite of copy that avoids unnecessarily running through Column instantiation.

I'll add a changelog entry once we agree where it should go.

Note that both are part of #1839; I'm splitting them out here as I think this is a bug that is easier to review separately (and yes, I'll take the rebase hit...).

In [1]: from astropy.table import Column; import numpy as np

In [2]: a = Column([0., np.inf, 1.], name='a')

In [3]: a
Out[3]: 
<Column name='a' unit=None format=None description=None>
array([  0.,  inf,   1.])

In [4]: np.isinf(a)
Out[4]: 
<Column name='a' unit=None format=None description=None>
array([False,  True, False], dtype=bool)

@astrofrog
Copy link
Member

👍

@embray
Copy link
Member

embray commented Sep 19, 2014

This seems reasonable to me,

@astrofrog
Copy link
Member

This needs a changelog entry. I think it can be considered a bug and included in 0.4.2.

@mhvk
Copy link
Contributor Author

mhvk commented Sep 21, 2014

@astrofrog - OK, changelog entry added.

@embray embray added this to the v0.4.2 milestone Sep 22, 2014
embray added a commit that referenced this pull request Sep 22, 2014
Ensure Column-ness is stripped for boolean ufuncs; faster copy
@embray embray merged commit c3ac937 into astropy:master Sep 22, 2014
@mhvk mhvk deleted the column-functions-with-boolean-output branch September 22, 2014 17:55
embray added a commit that referenced this pull request Sep 22, 2014
Ensure Column-ness is stripped for boolean ufuncs; faster copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants