Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: ufunc is not applied to sparse.fill_value #13853
Conversation
sinhrks
added Bug Sparse Compat
labels
Jul 30, 2016
sinhrks
added this to the
0.19.0
milestone
Jul 30, 2016
codecov-io
commented
Jul 30, 2016
•
Current coverage is 85.27% (diff: 93.33%)@@ master #13853 diff @@
==========================================
Files 139 139
Lines 50020 50031 +11
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 42657 42666 +9
- Misses 7363 7365 +2
Partials 0 0
|
gfyoung
commented on the diff
Jul 31, 2016
| @@ -829,6 +829,51 @@ def test_numpy_mean(self): | ||
| tm.assertRaisesRegexp(ValueError, msg, np.mean, | ||
| SparseArray(data), out=out) | ||
| + def test_abs(self): | ||
| + sparse = SparseArray([1, np.nan, 2, np.nan, -2]) | ||
| + result = SparseArray([1, np.nan, 2, np.nan, 2]) | ||
| + tm.assert_sp_array_equal(abs(sparse), result) | ||
| + tm.assert_sp_array_equal(np.abs(sparse), result) | ||
| + | ||
| + sparse = SparseArray([1, -1, 2, -2], fill_value=1) | ||
| + result = SparseArray([1, 2, 2], sparse_index=sparse.sp_index, |
sinhrks
Member
|
gfyoung
commented on an outdated diff
Jul 31, 2016
| @@ -829,6 +829,51 @@ def test_numpy_mean(self): | ||
| tm.assertRaisesRegexp(ValueError, msg, np.mean, | ||
| SparseArray(data), out=out) | ||
| + def test_abs(self): |
gfyoung
Member
|
gfyoung
commented on an outdated diff
Jul 31, 2016
| + tm.assert_sp_array_equal(abs(sparse), result) | ||
| + tm.assert_sp_array_equal(np.abs(sparse), result) | ||
| + | ||
| + sparse = SparseArray([1, -1, 2, -2], fill_value=1) | ||
| + result = SparseArray([1, 2, 2], sparse_index=sparse.sp_index, | ||
| + fill_value=1) | ||
| + tm.assert_sp_array_equal(abs(sparse), result) | ||
| + tm.assert_sp_array_equal(np.abs(sparse), result) | ||
| + | ||
| + sparse = SparseArray([1, -1, 2, -2], fill_value=-1) | ||
| + result = SparseArray([1, 2, 2], sparse_index=sparse.sp_index, | ||
| + fill_value=1) | ||
| + tm.assert_sp_array_equal(abs(sparse), result) | ||
| + tm.assert_sp_array_equal(np.abs(sparse), result) | ||
| + | ||
| + def test_ufunc1(self): |
gfyoung
Member
|
|
LGTM cc @jreback |
jreback
commented on an outdated diff
Aug 1, 2016
|
I understand why this is needed, but it feels a tad unnatural. I am not sure a user will be expecting that the fill value will have the ufunc be applied here. Can we add a section to the docs showing this? |
|
Sure, added small section. |
sinhrks commentedJul 30, 2016
git diff upstream/master | flake8 --diffWhen ufunc is applied to sparse, it is not applied to
fill_value. Thus results are incorrect.on current master:
cc @gfyoung