Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix passing shape (2,) input to Collections.set_offsets. #9232

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

Merged
merged 1 commit into from
Sep 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix passing shape (2,) input to Collections.set_offsets.
The logic with uniform_offsets seems a bit crazy but let's just
reproduce it for now...
  • Loading branch information
anntzer authored and tacaswell committed Sep 28, 2017
commit c5170ec00f6b7b725ad63e68f95f12fd5666efcd
17 changes: 10 additions & 7 deletions 17 lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ def __init__(self,
self.set_offset_position(offset_position)
self.set_zorder(zorder)

self._offsets = np.zeros((1, 2))
self._uniform_offsets = None
self._offsets = np.array([[0, 0]], float)
if offsets is not None:
offsets = np.asanyarray(offsets, float)
# Broadcast (2,) -> (1, 2) but nothing else.
if offsets.shape == (2,):
offsets = offsets[None, :]
if transOffset is not None:
self._offsets = offsets
self._transOffset = transOffset
Expand Down Expand Up @@ -400,7 +403,7 @@ def set_hatch(self, hatch):
self.stale = True

def get_hatch(self):
'Return the current hatching pattern'
"""Return the current hatching pattern."""
return self._hatch

def set_offsets(self, offsets):
Expand All @@ -411,18 +414,18 @@ def set_offsets(self, offsets):
ACCEPTS: float or sequence of floats
"""
offsets = np.asanyarray(offsets, float)
#This decision is based on how they are initialized above
if offsets.shape == (2,): # Broadcast (2,) -> (1, 2) but nothing else.
offsets = offsets[None, :]
# This decision is based on how they are initialized above in __init__.
if self._uniform_offsets is None:
self._offsets = offsets
else:
self._uniform_offsets = offsets
self.stale = True

def get_offsets(self):
"""
Return the offsets for the collection.
"""
#This decision is based on how they are initialized above in __init__()
"""Return the offsets for the collection."""
# This decision is based on how they are initialized above in __init__.
if self._uniform_offsets is None:
return self._offsets
else:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.