From: Jochen V. <vo...@se...> - 2004-10-30 12:22:47
|
Hello, currently I am having a closer look at the PostScript backend. Some questions occurred to me: 1) What is the meaning of 'backend_version'? When should it be increased/changed? 2) Is the following code the correct way to get the matplotlib version for use in a backend file: from matplotlib import __version__ version=3D__version__ 3) The draw_lines method checks whether the argument arrays are of the same size as required. The other functions do not do any sanity checks on the arguments. Can the renderer methods assume that they are called with semantically correct arguments? Is it ok to fail with an Python exception otherwise? 4) Can the PostScript code assume that each file contains only one picture/page? Might this change in the future? 5) Does matplotlib have the concept of a picture title which could be written into the DSC "%%Title" comment? If the answer is yes: how do I get this title? Also I have some questions about the template backend in backend_template.py: 6) The template backend contains the line from matplotlib.transforms import Bbox Does this have any function or should it be removed? 7) The template backend uses=20 verbose.report('Error: %s'%msg) Should this be 'verbose.report_error' instead? Sorry about having so many questions, Jochen --=20 http://seehuhn.de/ |
From: Steve C. <ste...@ya...> - 2004-10-31 14:08:11
|
> 7) The template backend uses=20 > > verbose.report('Error: %s'%msg) > > Should this be 'verbose.report_error' instead? I was looking at this too, earlier today, because it was giving me a problem - it was exiting without the error message being printed. I looked to see how backend_agg handles errors and deleted it because I don't think its even needed. With a GUI backend you can popup an error message window. With a non-GUI backend you can simply use "from matplotlib.backend_bases import error_msg" as backend_agg does. backend_bases has: def error_msg(msg, *args, **kwargs): """ Alert an error condition with message """ print >>sys.stderr, msg sys.exit() No verbose() at all! But I agree I think it should be 'verbose.report_error' Also, there is a new PS backend now. I've been working on backend_cairo.py and today got it producing its own png and PS files. Regards, Steve |
From: Jochen V. <vo...@se...> - 2004-10-31 15:59:23
|
Hello, On Sun, Oct 31, 2004 at 10:09:55PM +0800, Steve Chaplin wrote: > backend_bases has: > def error_msg(msg, *args, **kwargs): > """ > Alert an error condition with message > """ > print >>sys.stderr, msg > sys.exit() >=20 > No verbose() at all! But I agree I think it should be > 'verbose.report_error'=20 Yes, it seems that this makes sense in the non-interactive case. We are aborting the program, so the message should be visible in any case. > Also, there is a new PS backend now. I've been working on > backend_cairo.py and today got it producing its own png and PS files. Cool! All the best, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-10-31 16:42:21
|
>>>>> "Steve" == Steve Chaplin <ste...@ya...> writes: Hi Steve, >> 7) The template backend uses=20 >> >> verbose.report('Error: %s'%msg) >> >> Should this be 'verbose.report_error' instead? Yes. Steve> No verbose() at all! But I agree I think it should be Steve> 'verbose.report_error' Yes, it should. All printing should either go to verbose.report or verbose.report_error, so that the user specified output handles are used. This was just an oversight in backend_bases.error_msg. Everyone should feel free to fix these as they find them. Of course, GUI backends are an exception, where the error messages go to the dialog box, as you noted. >> Also, there is a new PS backend now. I've been working on >> backend_cairo.py and today got it producing its own png and PS >> files. Great - there have been a number of people who've been interested in a cairo backend since the earliest days. When you get the thing so that you're happy with it, you might want to search for cairo on the mailing list and let these people know there is one. Thanks! JDH |
From: Jochen V. <vo...@se...> - 2004-11-02 17:34:14
|
Hello, On Sun, Oct 31, 2004 at 10:33:27AM -0600, John Hunter wrote: > >> 7) The template backend uses=3D20 > >>=20 > >> verbose.report('Error: %s'%msg) > >>=20 > >> Should this be 'verbose.report_error' instead? >=20 > Yes. >=20 > Steve> No verbose() at all! But I agree I think it should be > Steve> 'verbose.report_error' >=20 > Yes, it should. All printing should either go to verbose.report or > verbose.report_error, so that the user specified output handles are > used. This was just an oversight in backend_bases.error_msg. > Everyone should feel free to fix these as they find them. Then the recent change to error_msg_template should be reverted, shouldn't it? All the best, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-11-02 18:58:37
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> Then the recent change to error_msg_template should be Jochen> reverted, shouldn't it? I don't know why is was changed (or what it was before). I just checked in def error_msg_template(msg, *args): """ Signal an error condition. - in a GUI backend, popup a error dialog. - in a non-GUI backend delete this function and use 'from matplotlib.backend_bases import error_msg' """ verbose.report_error(msg) raise SystemExist All opposed, say Nay! JDH |
From: Jochen V. <vo...@se...> - 2004-11-02 19:29:30
|
Hello John, On Tue, Nov 02, 2004 at 12:49:28PM -0600, John Hunter wrote: > I don't know why is was changed (or what it was before). I think it was just a misunderstanding about how error reporting is supposed to work. > def error_msg_template(msg, *args): > """ > Signal an error condition. > - in a GUI backend, popup a error dialog. > - in a non-GUI backend delete this function and use > 'from matplotlib.backend_bases import error_msg' > """ > verbose.report_error(msg) > raise SystemExist >=20 > All opposed, say Nay! I agree with the code, but I am not the sure about the comment. All the best, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-10-31 16:55:59
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> Hello, currently I am having a closer look at the Jochen> PostScript backend. Some questions occurred to me: Jochen> 1) What is the meaning of 'backend_version'? When should Jochen> it be increased/changed? Eg, for gtk this would be the version of pygtk, for wx the version of wxpython. It is mainly used to provide us diagnositic information to help when users post problems on the mailing list. If they run with --debug-helpful, we get the version info. It is not the same as the matplotlib version, which is reported separately. For PS, it seems that it should be the PS level that is required (PS level I, level II). But it could also be 'not applicable'. If you can think of something that makes sense, use it. Jochen> 2) Is the following code the correct way to get the Jochen> matplotlib version for use in a backend file: Jochen> from matplotlib import __version__ version=__version__ Looks right to me; you could also do from matplotlib import __version__ as version Jochen> 3) The draw_lines method checks whether the argument Jochen> arrays are of the same size as required. The other Jochen> functions do not do any sanity checks on the arguments. Jochen> Can the renderer methods assume that they are called with Jochen> semantically correct arguments? Is it ok to fail with an Jochen> Python exception otherwise? Yes on both cases, me thinks. Jochen> 4) Can the PostScript code assume that each file contains Jochen> only one picture/page? Might this change in the future? I say yes. I can't imagine changing this, but perhaps someelse who is more imaginative than I could. Jochen> 5) Does matplotlib have the concept of a picture title Jochen> which could be written into the DSC "%%Title" comment? If Jochen> the answer is yes: how do I get this title? Well, there is a figure title and an axes title. It would be easy to add a renderer method called set_title which is called by figure.draw and axes.draw. The problem here is that although there *is* a figure title (see matplotlib.matlab.figtitle) the most common way to set titles is via matplotlib.matlab.title which sets the title of the current axes. Hence you could have multiple titles. One solution, that will work in 95% of the cases, is just to use the first call to set_title in the renderer and ignore subsequent calls. This will get the figure title if there is one, and the first axes title if there isn't. Jochen> Also I have some questions about the template backend in Jochen> backend_template.py: Jochen> 6) The template backend contains the line Jochen> from matplotlib.transforms import Bbox Jochen> Does this have any function or should it be removed? It can be removed. Jochen> 7) The template backend uses Jochen> verbose.report('Error: %s'%msg) Jochen> Should this be 'verbose.report_error' instead? Yes. Jochen> Sorry about having so many questions, Jochen -- Thanks! JDH |