MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_array_unchecked_fixed_dims

Function test_array_unchecked_fixed_dims

tests/test_numpy_array.py:429–452  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

427
428
429def test_array_unchecked_fixed_dims(msg):
430 z1 = np.array([[1, 2], [3, 4]], dtype="float64")
431 m.proxy_add2(z1, 10)
432 assert np.all(z1 == [[11, 12], [13, 14]])
433
434 with pytest.raises(ValueError) as excinfo:
435 m.proxy_add2(np.array([1.0, 2, 3]), 5.0)
436 assert (
437 msg(excinfo.value) == "array has incorrect number of dimensions: 1; expected 2"
438 )
439
440 expect_c = np.ndarray(shape=(3, 3, 3), buffer=np.array(range(3, 30)), dtype="int")
441 assert np.all(m.proxy_init3(3.0) == expect_c)
442 expect_f = np.transpose(expect_c)
443 assert np.all(m.proxy_init3F(3.0) == expect_f)
444
445 assert m.proxy_squared_L2_norm(np.array(range(6))) == 55
446 assert m.proxy_squared_L2_norm(np.array(range(6), dtype="float64")) == 55
447
448 assert m.proxy_auxiliaries2(z1) == [11, 11, True, 2, 8, 2, 2, 4, 32]
449 assert m.proxy_auxiliaries2(z1) == m.array_auxiliaries2(z1)
450
451 assert m.proxy_auxiliaries1_const_ref(z1[0, :])
452 assert m.proxy_auxiliaries2_const_ref(z1)
453
454
455def test_array_unchecked_dyn_dims():

Callers

nothing calls this directly

Calls 2

msgFunction · 0.85
arrayMethod · 0.80

Tested by

no test coverage detected