mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
lint
This commit is contained in:
parent
4d8b37688c
commit
0645585d2d
@ -224,16 +224,17 @@ struct EigenProps {
|
||||
= !show_c_contiguous && show_order && requires_col_major;
|
||||
|
||||
static constexpr auto descriptor
|
||||
= const_name("numpy.typing.NDArray[") + npy_format_descriptor<Scalar>::name + const_name("[")
|
||||
+ const_name<fixed_rows>(const_name<(size_t) rows>(), const_name("m")) + const_name(", ")
|
||||
+ const_name<fixed_cols>(const_name<(size_t) cols>(), const_name("n")) + const_name("]")
|
||||
+
|
||||
= const_name("numpy.typing.NDArray[") + npy_format_descriptor<Scalar>::name
|
||||
+ const_name("[") + const_name<fixed_rows>(const_name<(size_t) rows>(), const_name("m"))
|
||||
+ const_name(", ") + const_name<fixed_cols>(const_name<(size_t) cols>(), const_name("n"))
|
||||
+ const_name("]") +
|
||||
// For a reference type (e.g. Ref<MatrixXd>) we have other constraints that might need to
|
||||
// be satisfied: writeable=True (for a mutable reference), and, depending on the map's
|
||||
// stride options, possibly f_contiguous or c_contiguous. We include them in the
|
||||
// descriptor output to provide some hint as to why a TypeError is occurring (otherwise
|
||||
// it can be confusing to see that a function accepts a 'numpy.typing.NDArray[float64[3,2]]' and
|
||||
// an error message that you *gave* a numpy.ndarray of the right type and dimensions.
|
||||
// it can be confusing to see that a function accepts a
|
||||
// 'numpy.typing.NDArray[float64[3,2]]' and an error message that you *gave* a
|
||||
// numpy.ndarray of the right type and dimensions.
|
||||
const_name<show_writeable>(", flags.writeable", "")
|
||||
+ const_name<show_c_contiguous>(", flags.c_contiguous", "")
|
||||
+ const_name<show_f_contiguous>(", flags.f_contiguous", "") + const_name("]");
|
||||
|
@ -105,8 +105,9 @@ def test_mutator_descriptors():
|
||||
)
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.fixed_mutator_a(np.array([[1, 2], [3, 4]], dtype="float32"))
|
||||
assert "(arg0: numpy.typing.NDArray[numpy.float32[5, 6], flags.writeable]) -> None" in str(
|
||||
excinfo.value
|
||||
assert (
|
||||
"(arg0: numpy.typing.NDArray[numpy.float32[5, 6], flags.writeable]) -> None"
|
||||
in str(excinfo.value)
|
||||
)
|
||||
zr.flags.writeable = False
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -268,7 +268,8 @@ def test_round_trip_references_actually_refer(m):
|
||||
@pytest.mark.parametrize("m", submodules)
|
||||
def test_doc_string(m, doc):
|
||||
assert (
|
||||
doc(m.copy_tensor) == "copy_tensor() -> numpy.typing.NDArray[numpy.float64[?, ?, ?]]"
|
||||
doc(m.copy_tensor)
|
||||
== "copy_tensor() -> numpy.typing.NDArray[numpy.float64[?, ?, ?]]"
|
||||
)
|
||||
assert (
|
||||
doc(m.copy_fixed_tensor)
|
||||
|
Loading…
Reference in New Issue
Block a user