lun. 14 janvier 2019
Tags : Cython Tips

Cython - How to compile

Cython is a tool that allows you to compile your code to C, resulting in a huge speed increase. All is needed is slight modification of the python code. The Cython documentation : http://docs.cython.org/en/latest/ If you only need to compile some Cython file (.pyx extension), here …


lun. 04 octobre 2010

Numpy tips

np.where(np.diff(np.sign(x)))[0] Find points of x crossing the threshold T : np.where(np.diff(x > T))[0] Find points of x crossing threshold ascending : np.where(np.diff(x > T) & (x[1:] > T)) Remove points that are close, i.e. given a sorted array …

lun. 04 octobre 2010

Python tips

Datetime Get the current date/time and format it (e.g. to create a filename) : import datetime print(datetime.datetime.now().strftime('%d%b%Y-%Hh%M')) >> '10Oct2018-18h01' See Comportement de strftime() et strptime() for the availables directives