[matplotlib-devel] mathtext SoC update
I'm still alive ;) Although I still haven't received any payments from Google (they are doing their best to solve this), I've began working on implementing the Knuth's layout algorithms. I have studied a bit the TeXbook, the existing mathtext parsing code, and I have decided to rewrite the parsing almost from scratch. Although I don't no too much about parsing, I think it won't be that much of a problem. My idea is to first transform a TeX string to a Python list (tree-like structure), which can be composed of strings, commands, and/or other lists, and so on. Then, I plan to write some classes to trasnform this list/tree to the actual boxes needed for displaying. The first part is done (although bugs are possible). Now I'm concetrating on the remaining part. The current module is attached. It doesn't need any third-party libraries currently. The following works: Going from: r"asdf { \horse{}\ \zztop{} \ Hello\^^a^{b_c}}" to: ['asdf', ' ', [' ', '\\horse', [], '\\space', '\\zztop', [], ' ', '\\space', 'Hello', '\\circumflex', '\\superscript', 'a', '\\superscript', ['b', '\\subscript', 'c']]] Please John, do comment (others with spare time are welcome too :). #~ from matplotlib.pyparsing import Literal, Word, OneOrMore, ZeroOrMore, \ #~ Combine, Group, Optional, Forward, NotAny, alphas, nums, alphanums, \ #~ StringStart, StringEnd, ParseException, FollowedBy, Regex esc_char = '\\' # Grouping delimiters begin_group_char = '{' end_group_char = '}' dec_delim = '.' word_delim = ' ' enviroment = { 'rm' : 'rm' } # Maximum number of nestings (groups within groups) max_depth = 10 class TexParseError(Exception): pass # Helper functions, mainly used by the parser def debug_tok(tok): print tok #pass def is_command(tok): pass def remove_comments(texstring): # TO-DO return texstring def group_split(texstring): """Splits the string into three parts based on the grouping delimiters, and returns them as a list. """ if texstring == begin_group_char + end_group_char: return '', [], '' length = len(texstring) i = texstring.find(begin_group_char) if i == -1: return texstring, '', '' pos_begin = i count = 1 num_groups = 0 while count != 0: i = i + 1 # First we check some things if num_groups > max_depth: message = "Maximum number of nestings reached. Too many groups" raise TexParseError(message) if i == length: message = "Group not closed properly" raise TexParseError(message) if texstring[i] == end_group_char: count -= 1 elif texstring[i] == begin_group_char: num_groups += 1 count += 1 before = texstring[:pos_begin] if pos_begin + 1 == i: grouping = [] else: grouping = texstring[pos_begin + 1:i] after = texstring[i + 1:] return before, grouping, after def break_up_commands(texstring): """Breaks up a string (mustn't contain any groupings) into a list of commands and pure text. """ result = [] if not texstring: return result _texstrings = texstring.split(esc_char) for i, _texstring in enumerate(_texstrings): _command, _puretext = split_command(_texstring) if i == 0 and _texstrings[0]: # Case when the first command is a not a command but text result.append(_command) result.extend(_puretext) continue if _command: result.append(esc_char + _command) if _puretext: if _puretext[0] == word_delim: _puretext = _puretext[1:] result.extend(_puretext) return result def split_command(texstring): """Splits a texstring into a command part and a pure text (as a list) part""" if not texstring: return "", [] _puretext = [] _command, _rest = get_first_word(texstring) if not _command: _command = texstring[0] _rest = texstring[1:] while True: _word, _rest = get_first_word(_rest) if _word: _puretext.append(_word) if _rest: _puretext.extend(_rest[0]) if len(_rest) == 1: break _rest = _rest[1:] else: break return _command, _puretext def get_first_word(texstring): _word = "" i = 0 _length = len(texstring) if _length == 0: return "", "" if texstring[0].isalpha(): while _length > i and texstring[i].isalpha(): _word += texstring[i] i = i + 1 elif texstring[0].isdigit(): while _length > i and (texstring[i].isdigit() or texstring[i] == dec_delim): _word += texstring[i] i = i + 1 return _word, texstring[i:] def parse_mathtex(texstring): """Parses the normalized tex string and returns a list. Used recursively.
Re: [matplotlib-devel] mathtext SoC update
> "Edin" == Edin Salkovi§ <[EMAIL PROTECTED]> writes: Edin> I'm still alive ;) Although I still haven't received any Edin> payments from Google (they are doing their best to solve Edin> this), I've began working on implementing the Knuth's layout Edin> algorithms. OK, but I reiterate my point from my last post on the subject. The work you have done previously as far as I understand is still not usable. You need to develop a system wherein mathtext can be used with a set of unicode fonts, so that when the STYX fonts are released we can use them. Even if the example font set does not have full coverage, we need to develop a prototype so that users and developers can test your work. Something like - here are a set of test fonts: http://some.web.site - here are the changes you need to make to your rc file - here is a test script I think it is unproductive to move on to new projects before the first one is completed and usable. Or if am missing something and the work is usable, please provide a brief set of instructions as above so we can test it. JDH - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] mathtext SoC update
John Hunter wrote: > the STYX fonts are released did you mean the STIX fonts? http://www.stixfonts.org/ > - here are a set of test fonts: http://some.web.site Is that really the link? -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] mathtext SoC update
On Wednesday 02 August 2006 11:59, Christopher Barker wrote: > John Hunter wrote: > > the STYX fonts are released > > did you mean the STIX fonts? > > http://www.stixfonts.org/ > > > - here are a set of test fonts: http://some.web.site > > Is that really the link? "Please repeat after me: I, say your name..." "I, say your name..." - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] mathtext SoC update
Darren Dale wrote: > I'm actually very hopeful. It's because the TeX code is so well written and > documented that the algorithms can (hopefully) be easily ported to Python. Good point. I've never looked deep enough to know how complicated the algorithms really are -- and we're not trying to build something that will run LaTeX here. Although, It would be very useful to be able to use add-on packages -- amsmath, if nothing else. > The problem I have with TeX is > that it has a lot of overhead (it's not meant to be used as a daemon), is not > intended to be used as a library (as far as I have been able to discern), These are key -- and what I've been fantasizing for years is that someone will re-write to be used as a library. > and > still requires interpretation once the results are produced DVI is actually pretty simple -- I don't think that's the hard part of the problem. > The usetex option, which produces excellent > results, has been an absolute headache to maintain across platforms. I'm sure! dependency on an external TeX distribution is not a good long-term option. > Which other projects did you have in mind? I've seen a couple that are trying to make a version of TeX that can be used as a lib -- with just this kind of thing in mind. How active they are, and whether they will get anywhere remains to be seen. Here's one that doesn't look active: http://www.metatex.org/ and another: but JAVA? argg! http://www.extex.org/index.html That might still be a good site to check out if one is to re-write the TeX layout engine in Python... Even if there aren't any other projects to leverage, while less fun, I expect that making a library version of TeX from the existing code base would result in a far more robust result. Another option is to build a stripped down TeX distribution that we would deliver with MPL. Also a lot of work, but it could be restricted to only a small number of fonts, packages, etc. Anyway, anything that someone will do (and get paid for!) is fine with me! -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] binary release for numpy 1.0
Any chance we can get a binary release together to work with the latest version of numpy? There are some posts on scipy-user complaining that 0.87.4 wont work with numpy C API version 100 (numpy-1.0b1). Darren - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] binary release for numpy 1.0
I have this on hand right now. http://euclid.uits.iupui.edu/~cmoad/matplotlib-0.87.4_r2645-py2.4-win32.egg I could make an exe build if you woudl prefer that. How long is numpy supposed to be in beta? - Charlie On 8/2/06, Darren Dale <[EMAIL PROTECTED]> wrote: > Any chance we can get a binary release together to work with the latest > version of numpy? There are some posts on scipy-user complaining that 0.87.4 > wont work with numpy C API version 100 (numpy-1.0b1). > > Darren > > - > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ___ > Matplotlib-devel mailing list > Matplotlib-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] binary release for numpy 1.0
Travis says that barring the discovery of some issue during the beta period, the C API will not change before numpy-1.1. I think an exe may be necessary as well. On Wednesday 02 August 2006 15:57, Charlie Moad wrote: > I have this on hand right now. > > http://euclid.uits.iupui.edu/~cmoad/matplotlib-0.87.4_r2645-py2.4-win32.egg > > I could make an exe build if you woudl prefer that. How long is numpy > supposed to be in beta? > > - Charlie > > On 8/2/06, Darren Dale <[EMAIL PROTECTED]> wrote: > > Any chance we can get a binary release together to work with the latest > > version of numpy? There are some posts on scipy-user complaining that > > 0.87.4 wont work with numpy C API version 100 (numpy-1.0b1). > > > > Darren > > > > - > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your opinions on IT & business topics through brief surveys -- and earn > > cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > ___ > > Matplotlib-devel mailing list > > Matplotlib-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel -- Darren S. Dale, Ph.D. Cornell High Energy Synchrotron Source Cornell University 200L Wilson Lab Rt. 366 & Pine Tree Road Ithaca, NY 14853 [EMAIL PROTECTED] office: (607) 255-9894 fax: (607) 255-9001 - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] binary release for numpy 1.0
Darren Dale wrote: > Travis says that barring the discovery of some issue during the beta period, > the C API will not change before numpy-1.1. I think an exe may be necessary > as well. and an OS-X mpkg, if you're set up to do that -- also, we'd need to build an mpkg of the numpy you used as well. I don't know if it's time to do that quite yet though. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel