DarkEnergySurvey / ugali

Ultra-faint galaxy likelihood toolkit
MIT License
14 stars 15 forks source link

rec_append_fields deprecation #43

Closed kadrlica closed 6 years ago

kadrlica commented 6 years ago

Matplotlib b2.2 has started warning that mlab.rec_append_fields is deprecated. There is a drop-in replacement in numpy.lib.recfunctions; however, it is a factor of 5x slower...

kadrlica commented 6 years ago
>>> import numpy as np
>>> import numpy.lib.recfunctions as recfn
>>> from matplotlib import mlab
>>> x = np.recarray(10000,dtype=[('x',int),('y',int)])
>>> %timeit -r 10000 -n 1 mlab.rec_append_fields(x,['z'],[np.zeros(len(x))])
MatplotlibDeprecationWarning: The rec_append_fields function was deprecated in version 2.2.
1 loop, best of 10000: 140 µs per loop
>>> %timeit -r 10000 -n 1 recfn.rec_append_fields(x,['z'],[np.zeros(len(x))])
1 loop, best of 10000: 684 µs per loop

Note that I'm doing 1e4 explicit runs to avoid any potential caching issues.

kadrlica commented 6 years ago

Closed by kadrlica/ugali#14