Open main menu

Changes

Matplotlib dateutil bug

784 bytes added, 17:45, 19 October 2015
Forced creation of a TOC - this will improve the formatting on the main page 'Did you know...' section.
__TOC__
 
== Background ==
When you create a range in relax, it is created as an xrange object.<br>
This is due to memory issues, which you can read about [http://thread.gmane.org/gmane.science.nmr.relax.devel/4862/focus=4865 here.]
You cannot by default slice through xrange objects.
The '''dateutil.rrule''' package (version 1.5) used in matplotlib/pylab creates some list, which it expects it can slice through.<br>'''dateutil.rrule''' package (version 2.2) does not have this problem. 
But relax will create these as '''xrange''' which is not-sliceable.
== Change bug in dateutil.rrule ==
The recommended way is to update your version of the '''python-dateutil''' package.
 
<source lang="bash">
sudo pip install python-dateutil --upgrade
</source>
 
If you by some means need to stay with the current versions, you can try.
<source lang="bash">
bash
echo $MFILE
sudo sed -i -e 's/range(1,30), range(1,31), range(1,32)/list(range(1,30)), list(range(1,31)), list(range(1,32))/g' $MFILE
sudo sed -i -e 's/range(-29,0), range(-30,0), range(-31,0)/list(range(-29,0)), list(range(-30,0)), list(range(-31,0))/g' $MFILE
</source>
Test if it worked
<source lang="bash">
$ relaxcat <<EOF > relax_test.pyrelax> from pylab import * t = arange(0.0, 2.0, 0.01)s = sin(2*pi*t)plot(t, s) xlabel('time (s)')ylabel('voltage (mV)')title('About as simple as it gets, folks')grid(True)show()EOF
relax relax_test.py
</source>
== See also ==
[[Category:matplotlib]]
Trusted, Bureaucrats
4,228

edits