Skip to content

Commit 0389fb1

Browse files
committed
Fix cbook style
- add missing functions to cbook.pyi - PEP8 format conform test
1 parent 787f308 commit 0389fb1

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/matplotlib/cbook.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,7 @@ def _setup_new_guiapp() -> None: ...
181181
def _format_approx(number: float, precision: int) -> str: ...
182182
def _g_sig_digits(value: float, delta: float) -> int: ...
183183
def _unikey_or_keysym_to_mplkey(unikey: str, keysym: str) -> str: ...
184+
def _is_torch_array(x: Any) -> bool: ...
185+
def _is_jax_array(x: Any) -> bool: ...
186+
def _unpack_to_numpy(x: Any) -> Any: ...
184187
def _auto_format_str(fmt: str, value: Any) -> str: ...

lib/matplotlib/tests/test_cbook.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -943,13 +943,18 @@ def test_auto_format_str(fmt, value, result):
943943

944944

945945
def test_unpack_to_numpy_from_torch():
946-
# Test that torch tensors are converted to NumPy arrays.
947-
# We don't want to create a dependency on torch in the test suite, so we mock it.
946+
"""
947+
Test that torch tensors are converted to NumPy arrays.
948+
949+
We don't want to create a dependency on torch in the test suite, so we mock it.
950+
"""
948951
class Tensor:
949952
def __init__(self, data):
950953
self.data = data
954+
951955
def __array__(self):
952956
return self.data
957+
953958
torch = ModuleType('torch')
954959
torch.Tensor = Tensor
955960
sys.modules['torch'] = torch
@@ -962,11 +967,15 @@ def __array__(self):
962967

963968

964969
def test_unpack_to_numpy_from_jax():
965-
# Test that jax arrays are converted to NumPy arrays.
966-
# We don't want to create a dependency on jax in the test suite, so we mock it.
970+
"""
971+
Test that jax arrays are converted to NumPy arrays.
972+
973+
We don't want to create a dependency on jax in the test suite, so we mock it.
974+
"""
967975
class Array:
968976
def __init__(self, data):
969977
self.data = data
978+
970979
def __array__(self):
971980
return self.data
972981

0 commit comments

Comments
 (0)