sankey.add() has mutable defaults #563

Merged
merged 2 commits into from Aug 21, 2012

Projects

None yet

3 participants

@WeatherGod
Matplotlib Developers member

While working to add api docs for sankey module, I noticed that the add() method contains mutable defaults. This could cause unexpected issues for users and should probably be fixed.

@pelson
Matplotlib Developers member

Confirming that the signature in sankey.py is:

    def add(self, patchlabel='', flows=np.array([1.0,-1.0]), orientations=[0,0],
            labels='', trunklength=1.0, pathlengths=0.25, prior=None,
            connect=(0,0), rotation=0, **kwargs):
@pelson pelson and 1 other commented on an outdated diff Aug 21, 2012
lib/matplotlib/sankey.py
@@ -245,9 +245,9 @@ def _revert(self, path, first_action=Path.LINETO):
#return path
@docstring.dedent_interpd
- def add(self, patchlabel='', flows=np.array([1.0, -1.0]),
- orientations=[0, 0], labels='', trunklength=1.0, pathlengths=0.25,
- prior=None, connect=(0, 0), rotation=0, **kwargs):
+ def add(self, patchlabel='', flows=None, orientations=[0, 0], labels='',
@pelson
pelson Aug 21, 2012

orientations is still mutable.

@mdboom
mdboom Aug 21, 2012

Ah, so it is. Will fix this also.

@mdboom
Matplotlib Developers member

I think this is good to merge now.

@WeatherGod
Matplotlib Developers member

Looks good to me as well. Merging...

@WeatherGod WeatherGod merged commit ff4bb1e into matplotlib:master Aug 21, 2012
@mdboom mdboom deleted the mdboom:issue563 branch Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment