sankey.add() has mutable defaults #563

merged 2 commits into from Aug 21, 2012


None yet

3 participants

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.

Matplotlib Developers member

Confirming that the signature in 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
@@ -245,9 +245,9 @@ def _revert(self, path, first_action=Path.LINETO):
#return path
- 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 Aug 21, 2012 Matplotlib Developers member

orientations is still mutable.

mdboom Aug 21, 2012 Matplotlib Developers member

Ah, so it is. Will fix this also.

Matplotlib Developers member

I think this is good to merge now.

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