RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility

According to MAINT: silence Cython warnings about changes dtype/ufunc size. – numpy/numpy: These warnings are visible whenever you import scipy (or another package) that was compiled against an older numpy than is installed. and the checks are inserted by Cython (hence are present in any module compiled with it). Long story short, these warnings should be benign … Read more

Python/Numpy MemoryError

Rewrite to and this will use much less memory. Whereas p = p*alpha allocates a whole new matrix for the result of p*alpha and then discards the old p; p*= alpha does the same thing in place. In general, with big matrices, try to use op= assignment.

AttributeError:’bytes’ object has no attribute ‘encode’

If you don’t know if a stringlike object is a Python 2 string (bytes) or Python 3 string (unicode). You could have a generic converter. Python3 shell: On Python 2 both these expressions evaluate to True: type(“hello”) == bytes and type(“hello”) == str. And type(u”hello”) == str evaluates to False, while type(u”hello”) == unicode is True. On Python 3 type(“hello”) == bytes is False, and type(“hello”) == str is True. And type(“hello”) … Read more

How to update a plot in matplotlib?

You essentially have two options: Do exactly what you’re currently doing, but call graph1.clear() and graph2.clear() before replotting the data. This is the slowest, but most simplest and most robust option. Instead of replotting, you can just update the data of the plot objects. You’ll need to make some changes in your code, but this should be much, much … Read more