Skip to content

WRN: let + * and - pass thru on boolean with a warning #7245

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

Merged
merged 1 commit into from
May 27, 2014
Merged

WRN: let + * and - pass thru on boolean with a warning #7245

merged 1 commit into from
May 27, 2014

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented May 27, 2014

closes #7210

if op_str in deprecated:
warnings.warn("operator %r is deprecated for bool dtype"
", use %r instead" % (op_str, deprecated[op_str]),
FutureWarning)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make it a UserWarning as its not deprecated per se, just not supported really ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@cpcloud cpcloud added this to the 0.14.0 milestone May 27, 2014
@cpcloud cpcloud self-assigned this May 27, 2014
@jorisvandenbossche
Copy link
Member

not supported also sounds a bit strange (as this is not clear that your code will actually work). In what regard is it not supported? Or is it just not recommended as it can have performance consequences?

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

ah right ... that reminds me i actually need to test this with numexpr which was the whole point! numexpr doesn't support boolean arithmetic, in this case that's what I mean when I say not supported

@jreback
Copy link
Contributor

jreback commented May 27, 2014

I thought u were going to do a warning, then just translate the symbols and do it anyhow

(e.g. '*' -> '&') etc

@jorisvandenbossche
Copy link
Member

ah, I thought you were going to detect this and then just use python evaluation and not numexpr (in that sense my comment above).

What I mean is: not supported <-> but my code will still run is not clear from the message now.

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

i see @jreback i misunderstood what you meant by translation...that's actually probably the simplest method

@jreback
Copy link
Contributor

jreback commented May 27, 2014

yes I agree with @jorisvandenbossche (that's even better), but I would still do the warning; you can just bail out of the evaluation and 'fallback' to python eval

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

ok so translate or no? very simple and would keep the performance for those ops (not that they are really used that much)

@jreback
Copy link
Contributor

jreback commented May 27, 2014

@cpcloud I think just fallback as @jorisvandenbossche suggests (with a warning)

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

ok

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

how about 'operator "BLAH" not supported by numexpr for bool dtype, use "BLARG" instead'?

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

still not totally clear that it works tho

@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

@jorisvandenbossche ok with the latest message?

@jorisvandenbossche
Copy link
Member

ok!

@jreback
Copy link
Contributor

jreback commented May 27, 2014

Looks good to me

need to adjust the release notes / v0.14.0.txt to reflect this (and add this issue number too).
go ahead do that and squash and can merge when ready.

In [2]: df = DataFrame(dict(A=np.random.randn(50000))).isnull()

In [3]: df*df
pandas/computation/expressions.py:184: UserWarning: evaluating in Python space because the '*' operator is not supported by numexpr for the bool dtype, use '&' instead
  unsupported[op_str]))
Out[3]: 
           A
0      False
1      False
2      False
3      False
4      False
5      False
6      False
7      False
8      False
9      False
10     False
11     False
12     False
13     False
14     False
15     False
16     False
17     False
18     False
19     False
20     False
21     False
22     False
23     False
24     False

But give a warning suggesting a better way to do it
@cpcloud
Copy link
Member Author

cpcloud commented May 27, 2014

@jreback good on the rls notes?

@jreback
Copy link
Contributor

jreback commented May 27, 2014

yep

cpcloud added a commit that referenced this pull request May 27, 2014
WRN: let + * and - pass thru on boolean with a warning
@cpcloud cpcloud merged commit 1fa5dd4 into pandas-dev:master May 27, 2014
@cpcloud cpcloud deleted the bool-warn-and-work-7210 branch May 27, 2014 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression: NotImplementedError: operator '*' not implemented for bool dtypes
3 participants