PythonOptimizers / cysparse

Python/Cython library to replace PySparse
http://PythonOptimizers.github.io/cysparse
7 stars 3 forks source link

Bug in CSC matrices: method `find()` #242

Closed syarra closed 8 years ago

syarra commented 8 years ago

line 470 of cysparse/sparse/csc_mat_matrices/csc_mat.cpx

should be

pi[ elem ] = self.row[k]

instead of

pi[ elem ] = self.row[j]

@counterclocker

ghost commented 8 years ago

Yes, indeed. What seemed to be a simple bug turned out to be much more difficult than that...

I added unittests for the find() method. It turns out that this did find another "bug": CPython PyInt_Check doesn't detect int32_t under an architecture with int == int64_t... Great!

ghost commented 8 years ago

See https://docs.python.org/2/c-api/int.html#c.PyInt_Check:

Return true if o is of type PyInt_Type or a subtype of PyInt_Type.

and https://docs.python.org/2/c-api/int.html#c.PyInt_Type:

This instance of PyTypeObject represents the Python plain integer type. This is the same object as int and types.IntType.

This means that under an architecture in 64 bits where int == int64_t, int32_t is NOT recognized as an int type...