mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Render full numpy numeric names (e.g. numpy.int32)
This commit is contained in:
committed by
Wenzel Jakob
parent
63df87fa49
commit
22b2504080
@@ -79,15 +79,17 @@ def test_mutator_descriptors():
|
||||
m.fixed_mutator_a(zc)
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.fixed_mutator_r(zc)
|
||||
assert ('(arg0: numpy.ndarray[float32[5, 6], flags.writeable, flags.c_contiguous]) -> None'
|
||||
assert ('(arg0: numpy.ndarray[numpy.float32[5, 6],'
|
||||
' flags.writeable, flags.c_contiguous]) -> None'
|
||||
in str(excinfo.value))
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.fixed_mutator_c(zr)
|
||||
assert ('(arg0: numpy.ndarray[float32[5, 6], flags.writeable, flags.f_contiguous]) -> None'
|
||||
assert ('(arg0: numpy.ndarray[numpy.float32[5, 6],'
|
||||
' flags.writeable, flags.f_contiguous]) -> None'
|
||||
in str(excinfo.value))
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.fixed_mutator_a(np.array([[1, 2], [3, 4]], dtype='float32'))
|
||||
assert ('(arg0: numpy.ndarray[float32[5, 6], flags.writeable]) -> None'
|
||||
assert ('(arg0: numpy.ndarray[numpy.float32[5, 6], flags.writeable]) -> None'
|
||||
in str(excinfo.value))
|
||||
zr.flags.writeable = False
|
||||
with pytest.raises(TypeError):
|
||||
@@ -179,7 +181,7 @@ def test_negative_stride_from_python(msg):
|
||||
m.double_threer(second_row)
|
||||
assert msg(excinfo.value) == """
|
||||
double_threer(): incompatible function arguments. The following argument types are supported:
|
||||
1. (arg0: numpy.ndarray[float32[1, 3], flags.writeable]) -> None
|
||||
1. (arg0: numpy.ndarray[numpy.float32[1, 3], flags.writeable]) -> None
|
||||
|
||||
Invoked with: """ + repr(np.array([ 5., 4., 3.], dtype='float32')) # noqa: E501 line too long
|
||||
|
||||
@@ -187,7 +189,7 @@ def test_negative_stride_from_python(msg):
|
||||
m.double_threec(second_col)
|
||||
assert msg(excinfo.value) == """
|
||||
double_threec(): incompatible function arguments. The following argument types are supported:
|
||||
1. (arg0: numpy.ndarray[float32[3, 1], flags.writeable]) -> None
|
||||
1. (arg0: numpy.ndarray[numpy.float32[3, 1], flags.writeable]) -> None
|
||||
|
||||
Invoked with: """ + repr(np.array([ 7., 4., 1.], dtype='float32')) # noqa: E501 line too long
|
||||
|
||||
@@ -607,17 +609,19 @@ def test_special_matrix_objects():
|
||||
|
||||
def test_dense_signature(doc):
|
||||
assert doc(m.double_col) == """
|
||||
double_col(arg0: numpy.ndarray[float32[m, 1]]) -> numpy.ndarray[float32[m, 1]]
|
||||
double_col(arg0: numpy.ndarray[numpy.float32[m, 1]]) -> numpy.ndarray[numpy.float32[m, 1]]
|
||||
"""
|
||||
assert doc(m.double_row) == """
|
||||
double_row(arg0: numpy.ndarray[float32[1, n]]) -> numpy.ndarray[float32[1, n]]
|
||||
"""
|
||||
assert doc(m.double_complex) == """
|
||||
double_complex(arg0: numpy.ndarray[complex64[m, 1]]) -> numpy.ndarray[complex64[m, 1]]
|
||||
"""
|
||||
assert doc(m.double_mat_rm) == """
|
||||
double_mat_rm(arg0: numpy.ndarray[float32[m, n]]) -> numpy.ndarray[float32[m, n]]
|
||||
double_row(arg0: numpy.ndarray[numpy.float32[1, n]]) -> numpy.ndarray[numpy.float32[1, n]]
|
||||
"""
|
||||
assert doc(m.double_complex) == ("""
|
||||
double_complex(arg0: numpy.ndarray[numpy.complex64[m, 1]])"""
|
||||
""" -> numpy.ndarray[numpy.complex64[m, 1]]
|
||||
""")
|
||||
assert doc(m.double_mat_rm) == ("""
|
||||
double_mat_rm(arg0: numpy.ndarray[numpy.float32[m, n]])"""
|
||||
""" -> numpy.ndarray[numpy.float32[m, n]]
|
||||
""")
|
||||
|
||||
|
||||
def test_named_arguments():
|
||||
@@ -654,10 +658,10 @@ def test_sparse():
|
||||
@pytest.requires_eigen_and_scipy
|
||||
def test_sparse_signature(doc):
|
||||
assert doc(m.sparse_copy_r) == """
|
||||
sparse_copy_r(arg0: scipy.sparse.csr_matrix[float32]) -> scipy.sparse.csr_matrix[float32]
|
||||
sparse_copy_r(arg0: scipy.sparse.csr_matrix[numpy.float32]) -> scipy.sparse.csr_matrix[numpy.float32]
|
||||
""" # noqa: E501 line too long
|
||||
assert doc(m.sparse_copy_c) == """
|
||||
sparse_copy_c(arg0: scipy.sparse.csc_matrix[float32]) -> scipy.sparse.csc_matrix[float32]
|
||||
sparse_copy_c(arg0: scipy.sparse.csc_matrix[numpy.float32]) -> scipy.sparse.csc_matrix[numpy.float32]
|
||||
""" # noqa: E501 line too long
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user