FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bugfix/test for #9336 integer overwrite in categorical by story645 · Pull Request #9340 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Next Next commit
bugfix for #9336 and test for integer overwrite
  • Loading branch information
story645 committed Oct 9, 2017
commit dfafe4218b0084b2389b14e955c3e619b89aa88c
7 changes: 4 additions & 3 deletions lib/matplotlib/category.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ def convert(value, unit, axis):
if isinstance(value, six.string_types):
return vmap[value]

vals = shim_array(value)
str_value = shim_array(value)
mapped_value = str_value.copy()

for lab, loc in vmap.items():
vals[vals == lab] = loc
mapped_value[str_value == lab] = loc

return vals.astype('float')
return mapped_value.astype("float")

@staticmethod
def axisinfo(unit, axis):
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_category.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ class TestStrCategoryConverter(object):
(['A', 'A', np.nan, 'B', -np.inf, 3.14, np.inf],
[('nan', -1), ('3.14', 0), ('A', 1), ('B', 2),
('-inf', 100), ('inf', 200)],
[1, 1, -1, 2, 100, 0, 200])]
ids = ["unicode", "single", "basic", "mixed"]
[1, 1, -1, 2, 100, 0, 200]),
(["!", "0"], [("!", 0), ("0", 1)], [0, 1])]

ids = ["unicode", "single", "basic", "mixed", "integer"]

@pytest.fixture(autouse=True)
def mock_axis(self, request):
Expand Down

Back | FazBrowse Home | New Git URL