@@ -54,27 +54,30 @@ in mind.
5454
5555 * install ``svnmerge.py `` in your PATH::
5656
57- wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/\
58- svnmerge/svnmerge.py
57+ > wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/\
58+ svnmerge/svnmerge.py
5959
6060 * get a svn copy of the maintenance branch and the trunk (see above)
6161 * Michael advises making the change on the branch and committing
6262 it. Make sure you svn upped on the trunk and have no local
6363 modifications, and then from the svn trunk do::
6464
65- > svnmerge.py merge
65+ > svnmerge.py merge
6666
6767 If you wish to merge only specific revisions (in an unusual
6868 situation), do::
6969
70- > svnmerge.py merge -rNNN1-NNN2
70+ > svnmerge.py merge -rNNN1-NNN2
7171
7272 where the ``NNN `` are the revision numbers. Ranges are also
7373 acceptable.
7474
7575 The merge may have found some conflicts (code that must be
7676 manually resolved). Correct those conflicts, build matplotlib and
77- test your choices.
77+ test your choices. If you have resolved any conflicts, you can
78+ let svn clean up the conflict files for you::
79+
80+ > svn -R resolved .
7881
7982 ``svnmerge.py `` automatically creates a file containing the commit
8083 messages, so you are ready to make the commit::
@@ -97,14 +100,7 @@ For `numpy <http://www.numpy.org>`_, use::
97100
98101For masked arrays, use::
99102
100- from numpy import ma
101-
102- (The earlier recommendation, :samp: `import matplotlib.numerix.npyma as ma `,
103- was needed temporarily during the development of the maskedarray
104- implementation as a separate package. As of numpy 1.1, it replaces the
105- old implementation. Note: ``from numpy import ma `` works with numpy < 1.1
106- *and * with numpy >= 1.1. ``import numpy.ma as ma `` works *only * with
107- numpy >= 1.1, so for now we must not use it.)
103+ import numpy.ma as ma
108104
109105For matplotlib main module, use::
110106
@@ -120,8 +116,17 @@ For matplotlib modules (or any other modules), use::
120116
121117We prefer this over the equivalent ``from matplotlib import cbook ``
122118because the latter is ambiguous whether ``cbook `` is a module or a
123- function to the new developer. The former makes it explcit that
124- you are importing a module or package.
119+ function to the new developer. The former makes it explicit that you
120+ are importing a module or package. There are some modules whose names
121+ may be ambiguous in the context of local variables, eg
122+ :mod: `matplotlib.lines ` or :mod: `matplotlib.colors `. When you want to
123+ disambiguate, use the prefix 'm' with the ``import some.thing as
124+ mthing `` syntax, eg::
125+
126+ import matplotlib.lines as mlines
127+ import matplotlib.transforms as transforms # OK
128+ import matplotlib.transforms as mtransforms # OK, if you want to disambiguate
129+ import matplotlib.transforms as mtrans # OK, if you want to abbreviate
125130
126131Naming, spacing, and formatting conventions
127132-------------------------------------------
@@ -138,15 +143,26 @@ throughout.
138143
139144* classes: ``Upper `` or ``MixedCase ``
140145
141- Personally, I prefer the shortest names that are still readable.
146+ Prefer the shortest names that are still readable.
142147
143148Also, use an editor that does not put tabs in files. Four spaces
144149should be used for indentation everywhere and if there is a file with
145- tabs or more or less spaces it is a bug -- please fix it.
150+ tabs or more or less spaces it is a bug -- please fix it. There are
151+ some tools to help automate this checking, such as `tabnanny
152+ <http://effbot.org/librarybook/tabnanny.htm> `_, which is part of the
153+ standard library::
154+
155+ In [3]: cd /home/titan/johnh/mpl/lib/matplotlib/
156+ /home/titan/johnh/python/svn/matplotlib.trunk/matplotlib/lib/matplotlib
157+
158+ In [4]: import tabnanny
146159
147- Please avoid spurious invisible spaces at the ends of lines.
148- (Tell your editor to strip whitespace from line ends when saving
149- a file.)
160+ In [5]: tabnanny.check('axis.py')
161+
162+ There is also `reindent.py
163+ <http://svn.python.org/projects/doctools/trunk/utils/reindent.py> `_
164+ which can be used to automatically change python files to use 4-space
165+ indents with no hard tab characters.
150166
151167Keep docstrings uniformly indented as in the example below, with
152168nothing to the left of the triple quotes. The
@@ -160,10 +176,10 @@ It may be preferable to use a temporary variable to replace a single
160176long line with two shorter and more readable lines.
161177
162178Please do not commit lines with trailing white space, as it causes
163- noise in svn diffs.
164-
165- If you are an emacs user, the following in your ``.emacs `` will cause
166- emacs to strip trailing white space upon saving for python, C and C++:
179+ noise in svn diffs. Tell your editor to strip whitespace from line
180+ ends when saving a file. If you are an emacs user, the following in
181+ your ``.emacs `` will cause emacs to strip trailing white space upon
182+ saving for python, C and C++:
167183
168184.. code-block :: cl
169185
@@ -172,7 +188,7 @@ emacs to strip trailing white space upon saving for python, C and C++:
172188 (lambda ()
173189 (add-hook 'write-file-functions 'delete-trailing-whitespace)))
174190
175- for older versions of emacs (emacs<22) you need to do:
191+ for older versions of emacs (emacs<22) you need to do:
176192
177193.. code-block :: cl
178194
@@ -218,17 +234,17 @@ artist constructor which looks for suitably named methods and calls
218234them with the value.
219235
220236As a general rule, the use of ``**kwargs `` should be reserved for
221- pass-through keyword arguments, as in the examaple above. If I intend
222- for all the keyword args to be used in some function and not passed
223- on, I just use the key/value keyword args in the function definition
224- rather than the ``**kwargs `` idiom.
225-
226- In some cases I want to consume some keys and pass through the others,
227- in which case I pop the ones I want to use locally and pass on the
228- rest, eg., I pop `` scalex `` and `` scaley `` in
229- :meth: `~matplotlib.axes.Axes.plot ` and assume the rest are
230- :meth: ` ~matplotlib.lines.Line2D ` keyword arguments. As an example of
231- a pop, passthrough usage, see :meth: `~matplotlib.axes.Axes.plot ` ::
237+ pass-through keyword arguments, as in the example above. If all the
238+ keyword args to be used in the function being declared, and not passed
239+ on, use the key/value keyword args in the function definition rather
240+ than the ``**kwargs `` idiom.
241+
242+ In some cases, you may want to consume some keys in the local
243+ function, and let others pass through. You can `` pop `` the ones to be
244+ used locally and pass on the rest. For example, in
245+ :meth: `~matplotlib.axes.Axes.plot `, `` scalex `` and `` scaley `` are
246+ local arguments and the rest are passed on as
247+ :meth: `~matplotlib.lines.Line2D ` keyword arguments ::
232248
233249 # in axes.py
234250 def plot(self, *args, **kwargs):
@@ -240,10 +256,6 @@ a pop, passthrough usage, see :meth:`~matplotlib.axes.Axes.plot`::
240256 self.add_line(line)
241257 lines.append(line)
242258
243- The :mod: `matplotlib.cbook ` function :func: `~matplotlib.cbook.popd ` is rendered
244- obsolete by the :func: `~dict.pop ` dictionary method introduced in Python 2.3,
245- so it should not be used for new code.
246-
247259Note there is a use case when ``kwargs `` are meant to be used locally
248260in the function (not passed on), but you still need the ``**kwargs ``
249261idiom. That is when you want to use ``*args `` to allow variable
@@ -269,7 +281,7 @@ forced to use ``**kwargs``. An example is
269281Documentation and Docstrings
270282============================
271283
272- matplotlib uses artist instrospection of docstrings to support
284+ matplotlib uses artist introspection of docstrings to support
273285properties. All properties that you want to support through ``setp ``
274286and ``getp `` should have a ``set_property `` and ``get_property ``
275287method in the :class: `~matplotlib.artist.Artist ` class. Yes, this is
@@ -290,8 +302,8 @@ Since matplotlib uses a lot of pass through ``kwargs``, eg. in every
290302function that creates a line (:func: `~matplotlib.pyplot.plot `,
291303:func: `~matplotlib.pyplot.semilogx `,
292304:func: `~matplotlib.pyplot.semilogy `, etc...), it can be difficult for
293- the new user to know which ``kwargs `` are supported. I have developed a
294- docstring interpolation scheme to support documentation of every
305+ the new user to know which ``kwargs `` are supported. matplotlib uses
306+ a docstring interpolation scheme to support documentation of every
295307function that takes a ``**kwargs ``. The requirements are:
296308
2973091. single point of configuration so changes to the properties don't
@@ -300,12 +312,13 @@ function that takes a ``**kwargs``. The requirements are:
3003122. as automated as possible so that as properties change the docs
301313 are updated automagically.
302314
303- I have added a :attr: `matplotlib.artist.kwdocd ` and
304- :func: `matplotlib.artist.kwdoc ` to faciliate this. They combine
315+ The functions :attr: `matplotlib.artist.kwdocd ` and
316+ :func: `matplotlib.artist.kwdoc ` to facilitate this. They combine
305317python string interpolation in the docstring with the matplotlib
306- artist introspection facility that underlies ``setp `` and ``getp ``. The
307- ``kwdocd `` is a single dictionary that maps class name to a docstring of
308- ``kwargs ``. Here is an example from :mod: `matplotlib.lines `::
318+ artist introspection facility that underlies ``setp `` and ``getp ``.
319+ The ``kwdocd `` is a single dictionary that maps class name to a
320+ docstring of ``kwargs ``. Here is an example from
321+ :mod: `matplotlib.lines `::
309322
310323 # in lines.py
311324 artist.kwdocd['Line2D'] = artist.kwdoc(Line2D)
@@ -331,12 +344,12 @@ passthrough ``kwargs``, eg. :meth:`matplotlib.axes.Axes.plot`::
331344
332345Note there is a problem for :class: `~matplotlib.artist.Artist `
333346``__init__ `` methods, eg. :meth: `matplotlib.patches.Patch.__init__ `,
334- which supports ``Patch `` ``kwargs ``, since the artist inspector cannot work
335- until the class is fully defined and we can't modify the
336- ``Patch.__init__.__doc__ `` docstring outside the class definition. I have
337- made some manual hacks in this case which violates the "single entry
338- point" requirement above; hopefully we'll find a more elegant solution
339- before too long .
347+ which supports ``Patch `` ``kwargs ``, since the artist inspector cannot
348+ work until the class is fully defined and we can't modify the
349+ ``Patch.__init__.__doc__ `` docstring outside the class definition.
350+ There are some some manual hacks in this case which violates theqq
351+ "single entry point" requirement above -- see the
352+ `` artist.kwdocd['Patch'] `` setting in :mod: ` matplotlib.patches ` .
340353
341354
342355.. _licenses :
@@ -345,11 +358,66 @@ Licenses
345358========
346359
347360Matplotlib only uses BSD compatible code. If you bring in code from
348- another project make sure it has a PSF, BSD, MIT or compatible
349- license. If not, you may consider contacting the author and asking
350- them to relicense it. GPL and LGPL code are not acceptible in the
351- main code base, though we are considering an alternative way of
361+ another project make sure it has a PSF, BSD, MIT or compatible license
362+ (see the Open Source Initiative `licenses page
363+ <http://www.opensource.org/licenses> `_ for details on individual
364+ licenses). If it doesn't, you may consider contacting the author and
365+ asking them to relicense it. GPL and LGPL code are not acceptable in
366+ the main code base, though we are considering an alternative way of
352367distributing L/GPL code through an separate channel, possibly a
353368toolkit. If you include code, make sure you include a copy of that
354369code's license in the license directory if the code's license requires
355- you to distribute the license with it.
370+ you to distribute the license with it. Non-BSD compatible licenses
371+ are acceptable in matplotlib toolkits (eg basemap), but make sure you
372+ clearly state the licenses you are using.
373+
374+ Why BSD compatible?
375+ -------------------
376+
377+ The two dominant license variants in the wild are GPL-style and
378+ BSD-style. There are countless other licenses that place specific
379+ restrictions on code reuse, but there is an important different to be
380+ considered in the GPL and BSD variants. The best known and perhaps
381+ most widely used license is the GPL, which in addition to granting you
382+ full rights to the source code including redistribution, carries with
383+ it an extra obligation. If you use GPL code in your own code, or link
384+ with it, your product must be released under a GPL compatible
385+ license. I.e., you are required to give the source code to other
386+ people and give them the right to redistribute it as well. Many of the
387+ most famous and widely used open source projects are released under
388+ the GPL, including sagemath, linux, gcc and emacs.
389+
390+ The second major class are the BSD-style licenses (which includes MIT
391+ and the python PSF license). These basically allow you to do whatever
392+ you want with the code: ignore it, include it in your own open source
393+ project, include it in your proprietary product, sell it,
394+ whatever. python itself is released under a BSD compatible license, in
395+ the sense that, quoting from the PSF license page::
396+
397+ There is no GPL-like "copyleft" restriction. Distributing
398+ binary-only versions of Python, modified or not, is allowed. There
399+ is no requirement to release any of your source code. You can also
400+ write extension modules for Python and provide them only in binary
401+ form.
402+
403+ Famous projects released under a BSD-style license in the permissive
404+ sense of the last paragraph are the BSD operating system, python and
405+ TeX.
406+
407+ There are two primary reasons why early matplotlib developers selected
408+ a BSD compatible license. We wanted to attract as many users and
409+ developers as possible, and many software companies will not use GPL code
410+ in software they plan to distribute, even those that are highly
411+ committed to open source development, such as `enthought
412+ <http://enthought.com> `_, out of legitimate concern that use of the
413+ GPL will "infect" their code base by its viral nature. In effect, they
414+ want to retain the right to release some proprietary code. Companies,
415+ and institutions in general, who use matplotlib often make significant
416+ contributions, since they have the resources to get a job done, even a
417+ boring one, if they need it in their code. Two of the matplotlib
418+ backends (FLTK and WX) were contributed by private companies.
419+
420+ The other reason is licensing compatibility with the other python
421+ extensions for scientific computing: ipython, numpy, scipy, the
422+ enthought tool suite and python itself are all distributed under BSD
423+ compatible licenses.
0 commit comments