Coder Social home page Coder Social logo

opensmfs / pycorrelate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tritemio/pycorrelate

22.0 22.0 7.0 115 KB

Fast and accurate cross-correlation over arbitrary time lags.

Home Page: https://pycorrelate.readthedocs.io

License: Other

Makefile 1.89% Python 95.67% Jupyter Notebook 2.44%
cross-correlation dls fcs

pycorrelate's People

Contributors

berna1111 avatar tritemio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pycorrelate's Issues

Crashes when used with lists instead of numpy arrays

  • 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

minor clarification of ucorrelate description

The documentation for ucorrelate says the following: "The classical text-book linear cross-correlation between two signals defined at uniformly spaced intervals." I know that it is fairly obvious, but it would nevertheless be good to restate as follows: "The classical textbook linear cross-correlation between two signals defined at uniformly-spaced intervals with the same interval size."

runtime performance of ucorrelate is disappointing

Issue moved from https://github.com/tritemio/pycorrelate/issues/7. Original author @Phillip-M-Feldman.

  • Pycorrelate version: 0.3
  • Python version: 3.6
  • Operating System: Windows 10

Description

I wrote a script to compare the runtime perforance of numpy.correlate and pycorrelate.ucorrelate. The input sequences have length 1e5, and the maximum lag of interest is 10,000. Since I can't specify a maximum lag with numpy.correlate, I used the mode='same' option.

Although numpy.correlate does the full cross-correlation, and was thus expected to be much slower, the results showed that it is actually faster (the following test results are based on 10 iterations in each case):

elapsed (wall time) | user CPU | system CPU

      numpy:  37.03 | 141.09   |   6.92
pycorrelate: 106.91 |  55.62   |  51.78

I'm wondering if you have any thoughts re. why the elapse time is worse for pycorrelate.ucorrelate. Also, have you considering using FFTs to speed up the calculations?

Hard to tell when it will finish

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

Description

Correlation tends to be a time-consuming task, and it would be nice to have some kind of progress bar to get an estimate for how long it's going to take. This should be rather easy to implement, as we know the length of the arrays. I suggest adding it as a optional parameter to the functions, like

pcorrelate(..., progress=False)

This way, users don't get unexpected output in their terminal, but they can enable this useful feature if they want to. I'm willing to work on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.