From: <ef...@us...> - 2007-07-27 23:34:33
|
Revision: 3624 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3624&view=rev Author: efiring Date: 2007-07-27 16:34:29 -0700 (Fri, 27 Jul 2007) Log Message: ----------- tweaked cbook.dedent, inspired by Fernando's version Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-07-27 15:45:26 UTC (rev 3623) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-07-27 23:34:29 UTC (rev 3624) @@ -543,6 +543,8 @@ first line. It differs from textwrap.dedent in its deletion of leading blank lines and its use of the first non-blank line to determine the indentation. + + It is also faster in most cases. """ if not s: # includes case of s is None return '' @@ -552,6 +554,9 @@ ii += 1 lines = lines[ii:] nshift = len(lines[0]) - len(lines[0].lstrip()) + # Don't use first line in case of """blah... + if ii == 0 and len(lines) > 1: + nshift = len(lines[1]) - len(lines[1].lstrip()) for i, line in enumerate(lines): nwhite = len(line) - len(line.lstrip()) lines[i] = line[min(nshift, nwhite):] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-23 17:59:23
|
Revision: 3733 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3733&view=rev Author: mdboom Date: 2007-08-23 10:59:21 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Extremely minor bugfix that prevents the cycle finder from printing out dictionaries. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-23 17:58:49 UTC (rev 3732) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-23 17:59:21 UTC (rev 3733) @@ -936,7 +936,7 @@ recurse(referent, start, all, current_path + [obj]) for obj in objects: - outstream.write("Examining: %r\n" % obj) + outstream.write("Examining: %r\n" % (obj,)) recurse(obj, obj, { }, []) if __name__=='__main__': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-28 19:20:13
|
Revision: 3745 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3745&view=rev Author: mdboom Date: 2007-08-28 12:20:08 -0700 (Tue, 28 Aug 2007) Log Message: ----------- Oops in last commit. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:17:21 UTC (rev 3744) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:20:08 UTC (rev 3745) @@ -572,7 +572,7 @@ # Get a regex that will remove *up to* nshift spaces from the # beginning of each line. If it isn't in the cache, generate it. unindent = _dedent_regex.get(nshift, None) - if unindent = None + if unindent is None: unindent = re.compile("\n\r?" + " ?" * nshift) _dedent_regex[nshift] = unindent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-28 19:49:33
|
Revision: 3746 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3746&view=rev Author: mdboom Date: 2007-08-28 12:49:29 -0700 (Tue, 28 Aug 2007) Log Message: ----------- A further optimization of the new dedent. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:20:08 UTC (rev 3745) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:49:29 UTC (rev 3746) @@ -573,10 +573,11 @@ # beginning of each line. If it isn't in the cache, generate it. unindent = _dedent_regex.get(nshift, None) if unindent is None: - unindent = re.compile("\n\r?" + " ?" * nshift) + unindent = re.compile("\n\r? {0,%d}" % nshift) _dedent_regex[nshift] = unindent result = unindent.sub("\n", s).strip() + print result return result This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-28 19:50:03
|
Revision: 3747 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3747&view=rev Author: mdboom Date: 2007-08-28 12:49:53 -0700 (Tue, 28 Aug 2007) Log Message: ----------- A further optimization of the new dedent. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:49:29 UTC (rev 3746) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-28 19:49:53 UTC (rev 3747) @@ -577,7 +577,6 @@ _dedent_regex[nshift] = unindent result = unindent.sub("\n", s).strip() - print result return result This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-07-03 16:09:29
|
Revision: 5711 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5711&view=rev Author: mdboom Date: 2008-07-03 09:08:52 -0700 (Thu, 03 Jul 2008) Log Message: ----------- O(n) implementation of Grouper.__iter__ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 14:30:41 UTC (rev 5710) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 16:08:52 UTC (rev 5711) @@ -1030,7 +1030,7 @@ >>> g.join('a', 'b') >>> g.join('b', 'c') >>> g.join('d', 'e') - >>> list(g.get()) + >>> list(g) [['a', 'b', 'c'], ['d', 'e']] >>> g.joined('a', 'b') True @@ -1079,14 +1079,25 @@ def __iter__(self): """ - Returns an iterator yielding each of the disjoint sets as a list. + Iterate over each of the disjoint sets as a list. + + The iterator is invalid if interleaved with calls to join(). """ - seen = set() - for elem, group in self._mapping.iteritems(): - if elem not in seen: + class Token: pass + token = Token() + + # Mark each group as we come across if by appending a token, + # and don't yield it twice + for group in self._mapping.itervalues(): + if not group[-1] is token: yield group - seen.update(group) + group.append(token) + # Cleanup the tokens + for group in self._mapping.itervalues(): + if group[-1] is token: + del group[-1] + def get_siblings(self, a): """ Returns all of the items joined with *a*, including itself. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |