It's possible we should back off to just issuing a deprecation warning in
Post by Yaroslav HalchenkoOn Tue, Jan 3, 2017 at 9:00 AM, Yaroslav Halchenko <
Sorry for coming too late to the discussion and after PR
"addressing"
the issue by issuing an error was merged [1].A I got burnt by new
behavior while trying to build fresh pandas release on Debian (we
are
freezing for release way too soon ;) ) -- some pandas tests failed
since
they rely on previous non-erroring behavior and we gotA numpy
1.12.0~b1
which included [1] in unstable/testing (candidate release) now.
I quickly glanced over the discussion but I guess I have missed
actual description of the problem being fixed here...A what was
it??
previous behavior, int**int->int made sense to me as it seemed to be
consistent with casting Python's pow result to int, somewhat
fulfilling
desired promise for in-place operations and being inline with
built-in
pow results as far as I see it (up to casting).
I believe this is exactly the behavior we preserved. Rather, we turned
some cases that previously often gave wrong results (involving
negative
integer powers) into errors.
hm... testing on current master (first result is from python's pow)
$> python -c "import numpy; print('numpy version: ', numpy.__version__);
a=2; b=-2; print(pow(a,b)); print(pow(numpy.array(a), b))"
('numpy version: ', '1.13.0.dev0+02e2ea8')
0.25
File "<string>", line 1, in <module>
ValueError: Integers to negative integer powers are not allowed.
testing on Debian's packaged beta
$> python -c "import numpy; print('numpy version: ', numpy.__version__);
a=2; b=-2; print(pow(a,b)); print(pow(numpy.array(a), b))"
('numpy version: ', '1.12.0b1')
0.25
File "<string>", line 1, in <module>
ValueError: Integers to negative integer powers are not allowed.
$> python -c "import numpy; print('numpy version: ', numpy.__version__);
a=2; b=-2; print(pow(a,b)); print(pow(numpy.array(a), b))"
('numpy version: ', '1.8.2')
0.25
0
what am I missing?
The pandas test suite triggered this behavior, but not intentionally,
and
https://github.com/pandas-dev/pandas/pull/14498
I don't think that was the full set of cases, e.g.
(git)hopa/sid-i386:~exppsy/pandas[bf-i386]
$> nosetests -s -v pandas/tests/test_expressions.
py:TestExpressions.test_mixed_arithmetic_series
test_mixed_arithmetic_series (pandas.tests.test_expressions.TestExpressions) ... ERROR
======================================================================
ERROR: test_mixed_arithmetic_series (pandas.tests.test_
expressions.TestExpressions)
----------------------------------------------------------------------
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 223, in test_mixed_arithmetic_series
self.run_series(self.mixed2[col], self.mixed2[col], binary_comp=4)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 164, in run_series
test_flex=False, **kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 93, in run_arithmetic_test
expected = op(df, other)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 715, in wrapper
result = wrap_results(safe_na_op(lvalues, rvalues))
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 676, in safe_na_op
return na_op(lvalues, rvalues)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 652, in na_op
raise_on_error=True, **eval_kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/computation/expressions.py",
line 210, in evaluate
**eval_kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/computation/expressions.py",
line 63, in _evaluate_standard
return op(a, b)
ValueError: Integers to negative integer powers are not allowed.
and being paranoid, I have rebuilt exact current master of pandas with
(git)hopa:~exppsy/pandas[master]git
$> PYTHONPATH=/home/yoh/proj/numpy nosetests -s -v
pandas/tests/test_expressions.py:TestExpressions.test_mixed_
arithmetic_series
test_mixed_arithmetic_series (pandas.tests.test_expressions.TestExpressions) ... ERROR
======================================================================
ERROR: test_mixed_arithmetic_series (pandas.tests.test_
expressions.TestExpressions)
----------------------------------------------------------------------
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 223, in test_mixed_arithmetic_series
self.run_series(self.mixed2[col], self.mixed2[col], binary_comp=4)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 164, in run_series
test_flex=False, **kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/tests/test_expressions.py",
line 93, in run_arithmetic_test
expected = op(df, other)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 715, in wrapper
result = wrap_results(safe_na_op(lvalues, rvalues))
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 676, in safe_na_op
return na_op(lvalues, rvalues)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/core/ops.py", line 652, in na_op
raise_on_error=True, **eval_kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/computation/expressions.py",
line 210, in evaluate
**eval_kwargs)
File "/home/yoh/deb/gits/pkg-exppsy/pandas/pandas/computation/expressions.py",
line 63, in _evaluate_standard
return op(a, b)
ValueError: Integers to negative integer powers are not allowed.
----------------------------------------------------------------------
Ran 1 test in 0.015s
FAILED (errors=1)
$> git describe --tags
v0.19.0-303-gb957f6f
$> PYTHONPATH=/home/yoh/proj/numpy python -c "import numpy; print('numpy
version: ', numpy.__version__); a=2; b=-2; print(pow(a,b));
print(pow(numpy.array(a), b))"
('numpy version: ', '1.13.0.dev0+02e2ea8')
0.25
File "<string>", line 1, in <module>
ValueError: Integers to negative integer powers are not allowed.
--
Yaroslav O. Halchenko
Center for Open Neuroscience http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion