Hi Mike,

2008/12/15 Michael Droettboom <md...@stsci.edu>:
> Angus McMorland wrote:
>> I think I've copied the usage suggested by the 'writing mathtext' page
>> in the mpl documentation (i.e. looking at its rst source [1]). That is
>> to say, the appearance of $ and the lack of \ are produced by the
>> extension, and not by me.
>>
> I see what you're saying now.  Sorry for the assumption.

No problems. Thank-you for developing these great tools.

<snip>

> You'll need to use raw strings (prefix the """ with an r) so that the \a
> will appear in the final string.

>> I get this error:
>>
>> writing output... index modules/calculate
>> /usr/lib/python2.5/site-packages/sphinx/ext/sphinxext/mathmpl.py:107:
>> Warning: Could not render math expression $lpha$
>>  Warning)
>> /usr/lib/python2.5/site-packages/sphinx/ext/sphinxext/mathmpl.py:107:
>> Warning: Could not render math expression $lpha = 2$
>>  Warning)

Excellent - the use of raw docstrings _does_ fix the errors during the
sphinx build.

> That doesn't seem to be the root of this problem, however, as these strings
> should at least render to *something*, though probably not what you want.
>
> The warning is hiding the real error here.  In mathmpl.py, after the line
> where the warning is emitted:
>
>           warnings.warn("Could not render math expression %s" % latex,
>                         Warning)
>
> Add the line:
>
>           raise
>
> and then post the output to this list?

Just an FYI so you can probably tell what was going on, without the
curative r'', and with raise in place, the error reported was:

writing output... index modules/calculate
/usr/lib/python2.5/site-packages/sphinx/ext/sphinxext/mathmpl.py:107:
Warning: Could not render math expression $lpha$
  Warning)
Exception occurred:
  File "/usr/lib/python2.5/site-packages/matplotlib/mathtext.py", line
1963, in raise_error
    raise ParseFatalException(msg + "\n" + s)
ParseFatalException: Expected end of math '$'
$lpha$ (at char 0), (line:1, col:1)

Next, I initially got no pictures (a silent fail) in my browser, but I
traced that back to an assumption that mathmpl makes that sphinx-build
is being run from the html directory, whereas I was running it from
one higher up the hierarchy (my docs directory). Running sphinx-build
from the appropriate location makes it all work.

Obviously this is fine for mpl's needs (and mine too, now I know the
tricks). If, however, you're interested in making this a little more
robust for general usage, then the path handling probably needs
tweaking. I think the problem is that mathmpl.latex2html puts the
_static directory in the current directory sphinx-build is run from,
whereas in the html it points to '../_static/', which is not the same
thing whenever html pages are being rendered at deeper directory
levels.

> Thanks,
> Mike

Thanks for the help,

Angus.
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to