Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Fix: Pandas indexing Error in collections#6148

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:masterfromhas2k1:fix-pandas-indexing
Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionslib/matplotlib/collections.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,7 +151,7 @@ def _get_value(val):
except TypeError:
if cbook.iterable(val) and len(val):
try:
float(val[0])
float(cbook.safe_first_element(val))
except (TypeError, ValueError):
pass # raise below
else:
Expand All@@ -164,7 +164,7 @@ def _get_bool(val):
if not cbook.iterable(val):
val = (val,)
try:
bool(val[0])
bool(cbook.safe_first_element(val))
except (TypeError, IndexError):
raise TypeError('val must be a bool or nonzero sequence of them')
return val
Expand Down
22 changes: 21 additions & 1 deletionlib/matplotlib/tests/test_collections.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,11 +11,12 @@
from nose.tools import assert_equal
import numpy as np
from numpy.testing import assert_array_equal, assert_array_almost_equal
from nose.plugins.skip import SkipTest

import matplotlib.pyplot as plt
import matplotlib.collections as mcollections
import matplotlib.transforms as mtransforms
from matplotlib.collections import EventCollection
from matplotlib.collections importCollection,EventCollection
from matplotlib.testing.decorators import cleanup, image_comparison


Expand DownExpand Up@@ -617,6 +618,25 @@ def test_size_in_xy():
ax.set_ylim(0, 30)


def test_pandas_indexing():
try:
import pandas as pd
except ImportError:
raise SkipTest("Pandas not installed")

# Should not fail break when faced with a
# non-zero indexed series
index = [11, 12, 13]
ec = fc = pd.Series(['red', 'blue', 'green'], index=index)
lw = pd.Series([1, 2, 3], index=index)
aa = pd.Series([True, False, True], index=index)

Collection(edgecolors=ec)
Collection(facecolors=fc)
Collection(linewidths=lw)
Collection(antialiaseds=aa)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

[8]ページ先頭

©2009-2025 Movatter.jp