Skip to content

Crashes when used with lists instead of numpy arrays #8

@kenogo

Description

@kenogo
  • Pycorrelate version: 0.3
  • Python version: 3.6.4
  • Operating System: Windows

Description

When you want to use the correlation algorithms with pythonic lists instead of numpy arrays, the program crashes badly. This could easily be fixed with a check on whether the function arguments are lists, and calling np.array() in that case.

What I Did

from pycorrelate import pcorrelate
X = [1,2]
Y = [3,4]
edges = [1,2,3,4]
pcorrelate(X, Y, edges)

The resulting crash is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\dispatcher.py", line 401, in _compile_for_args
    error_rewrite(e, 'typing')
  File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\dispatcher.py", line 344, in error_rewrite
    reraise(type(e), e, None)
  File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\six.py", line 668, in reraise
    raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
�[1m�[1m�[1mInvalid use of Function(<function diff at 0x000001AD75F4C488>) with argument(s) of type(s): (reflected list(int64))
 * parameterized
�[1mIn definition 0:�[0m
�[1m    All templates rejected with literals.�[0m
�[1mIn definition 1:�[0m
�[1m    All templates rejected without literals.�[0m
�[1mThis error is usually caused by passing an argument of a type that is unsupported by the named function.�[0m�[0m
�[0m�[1m[1] During: resolving callee type: Function(<function diff at 0x000001AD75F4C488>)�[0m
�[0m�[1m[2] During: typing of call at C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\pycorrelate\pycorrelate.py (111)
�[0m
�[1m
File "..\..\..\..\AppData\Local\Programs\Python\Python36\lib\site-packages\pycorrelate\pycorrelate.py", line 111:�[0m
�[1mdef pcorrelate(t, u, bins, normalize=False):
    <source elided>
        counts += imax - imin
�[1m    G = counts / np.diff(bins)
�[0m    �[1m^�[0m�[0m

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions