SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Mario O. <mar...@hp...> - 2007年12月02日 06:26:20
Hello,
first let me thank you for your excellent software - I think
it is just wonderful and very pleasant to use.
Two small things came up when I installed 0.91.1 into
my home directory (I didn't want to mess with the debian
packages since they are usually very fast in updating them)
This passage in the INSTALL file is misleading:
Note that if you install matplotlib anywhere other than the default
location, you will need to set the MATPLOTLIBDATA environment
variable to point to the install base dir.
Instead of setting MATPLOTLIBDATA to the base dir I specified
with setup.py install --prefix /home/mo/mpl I had to set
it to
/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mpl-data/
for mathtext to find its fonts.
Secondly this passage in matplotlib/mathtext.py
 544 if cached_font is None:
 545 try:
 546 font = FT2Font(basename)
 547 except RuntimeError:
 548 return None
Where an unfound font file is not reported but rather a None font object
is returned just causes a Null pointer exception to be raised very
shortly afterwards without the important info as to the
real reason. Maybe the RunTimeError should just be raised as is
or handled in a more informative manner?
Thanks again and sorry for my nitpicking,
Mario Oschwald
From: Michael D. <md...@st...> - 2007年12月03日 13:37:14
Mario Oschwald wrote:
> Hello,
> 
> first let me thank you for your excellent software - I think
> it is just wonderful and very pleasant to use.
> 
> Two small things came up when I installed 0.91.1 into
> my home directory (I didn't want to mess with the debian
> packages since they are usually very fast in updating them)
> 
> This passage in the INSTALL file is misleading:
> 
> Note that if you install matplotlib anywhere other than the default
> location, you will need to set the MATPLOTLIBDATA environment
> variable to point to the install base dir.
> 
> 
> Instead of setting MATPLOTLIBDATA to the base dir I specified
> with setup.py install --prefix /home/mo/mpl I had to set
> it to
> 
> /home/mo/mpl/lib/python2.4/site-packages/matplotlib/mpl-data/
> 
> for mathtext to find its fonts.
Was that necessary? I routinely install matplotlib to a non-standard 
location, and have never set MATPLOTLIBDATA. If MATPLOTLIBDATA is not 
set, it appears that matplotlib will look for the "mpl-data" directory 
underneath the main matplotlib directory. (Which in your case is 
/home/mo/mpl/lib/python2.4/site-packages/matplotlib/). I'm curious if 
you get errors without specifying MATPLOTLIBDATA, and what the error is. 
 Perhaps the INSTALL docs should be updated to clarify that you only 
need this if you install the data in a non-standard place *relative to* 
the source code...
> Secondly this passage in matplotlib/mathtext.py
> 
> 544 if cached_font is None:
> 545 try:
> 546 font = FT2Font(basename)
> 547 except RuntimeError:
> 548 return None
The intent of this code is "if the font isn't found, use a dummy 
character." Since there are so many different font configurations, and 
they're all a little brittle, I thought it better to warn and fail 
gracefully than to fail completely (and users can always use the "-We" 
to fail on warnings.) Otherwise, we run the risk of having some plots 
not working on all installations (because of font limitations, etc.)
However, the implementation isn't quite right because not all callers 
expect and deal with the 'None' result correctly. I have fixed this in 
-r4557. Can you please send a script that triggers this error, so I can 
ensure my patch corrects for it?
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2007年12月03日 15:10:38
[Brought conversation back to matplotlib-devel list].
Mario Oschwald wrote:
> Hello
> 
> Michael Droettboom wrote:
>> Mario Oschwald wrote:
>>> This passage in the INSTALL file is misleading:
>>>
>>> Note that if you install matplotlib anywhere other than the default
>>> location, you will need to set the MATPLOTLIBDATA environment
>>> variable to point to the install base dir.
>>>
>> Was that necessary? I routinely install matplotlib to a non-standard
>> location, and have never set MATPLOTLIBDATA. If MATPLOTLIBDATA is not
>> set, it appears that matplotlib will look for the "mpl-data" directory
>> underneath the main matplotlib directory. (Which in your case is
>> /home/mo/mpl/lib/python2.4/site-packages/matplotlib/). I'm curious if
>> you get errors without specifying MATPLOTLIBDATA, and what the error is.
>> Perhaps the INSTALL docs should be updated to clarify that you only
>> need this if you install the data in a non-standard place *relative to*
>> the source code...
> 
> You are right - if I unset that variable the mpl-data directory is found
> automagically ;-) Stupid me for reading INSTALL files :-). That passage
> should definitely be updated to reflect that behaviour.
I'm +1 on just removing the paragraph altogether. It only applies if 
someone did:
	python setup.py install --install-data=/some/weird/place
Is that a common enough use case to confuse the matter? (Obviously 
MATPLOTLIBDATA should be mentioned elsewhere in the docs, but it seems 
too unimportant for the main INSTALL file.)
>>> Secondly this passage in matplotlib/mathtext.py
>>>
>>> 544 if cached_font is None:
>>> 545 try:
>>> 546 font = FT2Font(basename)
>>> 547 except RuntimeError:
>>> 548 return None
>> The intent of this code is "if the font isn't found, use a dummy
>> character." Since there are so many different font configurations, and
>> they're all a little brittle, I thought it better to warn and fail
>> gracefully than to fail completely (and users can always use the "-We"
>> to fail on warnings.) Otherwise, we run the risk of having some plots
>> not working on all installations (because of font limitations, etc.)
>>
>> However, the implementation isn't quite right because not all callers
>> expect and deal with the 'None' result correctly. I have fixed this in
>> -r4557. Can you please send a script that triggers this error, so I can
>> ensure my patch corrects for it?
> 
> OK, I can understand that. If you set the MATPLOTLIBDATA environment variable
> to some wrong directory and the font file is not found it crashes right here
> when trying to access the returned None object without a prior check:
> 
> 669 if symbol_name is None:
> 670 warn("Unrecognized symbol '%s'. Substituting with a dummy symbol."
> 671 % sym.encode('ascii', 'backslashreplace'), MathTextWarning)
> 672 fontname = 'it'
> 673 cached_font = self._get_font(fontname)
> 674 num = 0x3F # currency character, for lack of anything better
> ->675 gid = cached_font.charmap[num]
> 
> Snipped stacktrace below:
> /home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py:671: MathTextWarning: Unrecognized symbol 'e'. Substituting with a dummy symbol.
> % sym.encode('ascii', 'backslashreplace'), MathTextWarning)
> IN FONTMAP
> ---lots of parsing---
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 2243, in symbol
> char = Char(c, self.get_state())
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 1211, in __init__
> self._update_metrics()
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 1217, in _update_metrics
> metrics = self._metrics = self.font_output.get_metrics(
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 464, in get_metrics
> info = self._get_info(font, font_class, sym, fontsize, dpi)
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 567, in _get_info
> cached_font, num, symbol_name, fontsize, slanted = \
> File "/home/mo/mpl/lib/python2.4/site-packages/matplotlib/mathtext.py", line 675, in _get_glyph
> gid = cached_font.charmap[num]
> AttributeError: 'NoneType' object has no attribute 'charmap'
> 
> You can trigger it with the attached script, provided you set the MATPLOTLIBDATA to something
> bad or remove the font file all together.
Thanks. r4557 fixes this. There will probably be another bugfix 
release (0.91.2 or something) in the near future that includes this change.
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: John H. <jd...@gm...> - 2007年12月03日 15:21:00
On Dec 3, 2007 9:10 AM, Michael Droettboom <md...@st...> wrote:
> I'm +1 on just removing the paragraph altogether. It only applies if
> someone did:
>
> python setup.py install --install-data=/some/weird/place
Yes, it should be removed. It predates the move of the data to
mpl-data in the matplotlib installation directory, and isn't really
needed anymore.
JDH
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /