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

Commitc89ad62

Browse files
committed
FIX: Accept array for zdir
While we have only documented 3-tuple, it makes sense to accept anarray, because a more complicated direction vector could likely becalculated through a rotation matrix.Closes#30868.
1 parentb70e324 commitc89ad62

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ def get_dir_vector(zdir):
5858
x, y, z : array
5959
The direction vector.
6060
"""
61-
ifzdir=='x':
61+
ifcbook._str_equal(zdir,'x'):
6262
returnnp.array((1,0,0))
63-
elifzdir=='y':
63+
elifcbook._str_equal(zdir,'y'):
6464
returnnp.array((0,1,0))
65-
elifzdir=='z':
65+
elifcbook._str_equal(zdir,'z'):
6666
returnnp.array((0,0,1))
6767
elifzdirisNone:
6868
returnnp.array((0,0,0))

‎lib/mpl_toolkits/mplot3d/tests/test_art3d.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
importnumpyasnp
2+
importnumpy.testingasnptest
3+
importpytest
24

35
importmatplotlib.pyplotasplt
46

57
frommatplotlib.backend_basesimportMouseEvent
68
frommpl_toolkits.mplot3d.art3dimport (
9+
get_dir_vector,
710
Line3DCollection,
811
Poly3DCollection,
912
_all_points_on_plane,
1013
)
1114

1215

16+
@pytest.mark.parametrize("zdir, expected", [
17+
("x", (1,0,0)),
18+
("y", (0,1,0)),
19+
("z", (0,0,1)),
20+
(None, (0,0,0)),
21+
((1,2,3), (1,2,3)),
22+
(np.array([4,5,6]), (4,5,6)),
23+
])
24+
deftest_get_dir_vector(zdir,expected):
25+
res=get_dir_vector(zdir)
26+
assertisinstance(res,np.ndarray)
27+
nptest.assert_array_equal(res,expected)
28+
29+
1330
deftest_scatter_3d_projection_conservation():
1431
fig=plt.figure()
1532
ax=fig.add_subplot(projection='3d')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp