Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sankey.add() has mutable defaults #563

Merged
merged 2 commits into from Aug 21, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/matplotlib/sankey.py
Expand Up @@ -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='',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orientations is still mutable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so it is. Will fix this also.

trunklength=1.0, pathlengths=0.25, prior=None, connect=(0, 0),
rotation=0, **kwargs):
"""
Add a simple Sankey diagram with flows at the same hierarchical level.

Expand Down Expand Up @@ -328,7 +328,10 @@ def add(self, patchlabel='', flows=np.array([1.0, -1.0]),
:meth:`finish`
"""
# Check and preprocess the arguments.
flows = np.array(flows)
if flows is None:
flows = np.array([1.0, -1.0])
else:
flows = np.array(flows)
n = flows.shape[0] # Number of flows
if rotation == None:
rotation = 0
Expand Down