BUG: sparse/lil: fix up Cython bugs in fused type lookup #3392

Closed
wants to merge 3 commits into
from

Projects

None yet

3 participants

Owner
pv commented Feb 25, 2014

Unfortunately, Cython's fused types aren't really ready for prime time.
Here, work around various signature lookup failures.

Cython (up to 0.20) fail to look up function signature for lil_insert
and lil_fancy_set. Look it up based on dtype manually instead.

@pv pv BUG: sparse/lil: fix up Cython bugs in fused type lookup
Cython (up to 0.20) fail to look up function signature for lil_insert
and lil_fancy_set.  Look it up based on dtype manually instead.
84cb181
@rgommers rgommers added this to the 0.14.0 milestone Feb 25, 2014
Owner

Fixes all errors with numpy 1.8.0 for me.

We have several other extensions using fused types, that are (presumably) not broken. But I don't see so quickly why these LIL functions should be different.

Owner

Still some issue for older numpy though, this is with 1.6.0 (many of these):

======================================================================
ERROR: test_base.TestLIL.test_fancy_indexing_set
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rgommers/.local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 2427, in test_fancy_indexing_set
    _test_set_slice(i, j)
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 2417, in _test_set_slice
    A[i, j] = 1
  File "/home/rgommers/Code/scipy/scipy/sparse/lil.py", line 317, in __setitem__
    i, j, x)
  File "_csparsetools.pyx", line 245, in scipy.sparse._csparsetools.lil_fancy_set (../scipy/sparse/_csparsetools.c:13807)
ValueError: Unsupported data type

======================================================================
ERROR: test_base.TestLIL.test_inplace_ops
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rgommers/.local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 3422, in test_inplace_ops
    'mul': (3,A * 3)}
  File "/home/rgommers/Code/scipy/scipy/sparse/base.py", line 304, in __mul__
    return self._mul_scalar(other)
  File "/home/rgommers/Code/scipy/scipy/sparse/lil.py", line 330, in _mul_scalar
    rowvals in new.data]
ValueError: output operand requires a reduction, but reduction is not enabled
Owner
pv commented Feb 25, 2014

The first issue seems to be some damned dtype equality comparison bug in Numpy. Pushed a commit with fix.

The second of those seems unrelated to this PR.

Owner
pv commented Feb 25, 2014

Fixed also the second one. Some object array issue in Numpy...

@pv pv added the PR label Feb 25, 2014

Coverage Status

Changes Unknown when pulling 56365d0 on pv:fix-lil-assign into * on scipy:master*.

Coverage Status

Changes Unknown when pulling 56365d0 on pv:fix-lil-assign into * on scipy:master*.

Owner

One new set of errors when testing with this PR (77x) and numpy 1.6.0:

======================================================================
ERROR: test_base.Test64Bit.test_resiliency_limit_10(<class 'test_base.TestLIL'>, 'test_sequence_assignment')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rgommers/.local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/rgommers/.local/lib/python2.7/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "<string>", line 2, in check
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 105, in deco
    return func(*a, **kw)
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 3894, in check
    getattr(instance, method_name)()
  File "/home/rgommers/Code/scipy/scipy/sparse/tests/test_base.py", line 2454, in test_sequence_assignment
    A[0,i0] = B[i0,0].T
  File "/home/rgommers/Code/scipy/scipy/sparse/lil.py", line 317, in __setitem__
    i, j, x)
  File "_csparsetools.pyx", line 259, in scipy.sparse._csparsetools.lil_fancy_set (../scipy/sparse/_csparsetools.c:13959)
ValueError: Unsupported data type: 'i'

If that is fixed then 1.6.0 + 32-bit works. 1.5.1 has another issue still, unrelated to this PR. will comment on gh-3330

@rgommers rgommers added a commit that referenced this pull request Feb 26, 2014
@rgommers rgommers Merge branch 'fix-lil-assign' into master.
Review at #3392
e735f47
Owner

OK added a fix for missing entries in the dtype dict for i and I in 54813f9, and merged this PR in e735f47.

@rgommers rgommers closed this Feb 26, 2014
Owner

All tests now pass with 1.8.0 and 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment