Lines Matching refs:np

8     import numpy as np
10 ref = np.array([[ 0., 3, 0, 0, 0, 11],
18 np.testing.assert_array_equal(mat, ref)
44 ref2 = np.array([[0., 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]])
45 np.testing.assert_array_equal(m.partial_copy_four_rm_r(ref2), ref2)
46 np.testing.assert_array_equal(m.partial_copy_four_rm_c(ref2), ref2)
47 np.testing.assert_array_equal(m.partial_copy_four_rm_r(ref2[:, 1]), ref2[:, [1]])
48 np.testing.assert_array_equal(m.partial_copy_four_rm_c(ref2[0, :]), ref2[[0], :])
49 np.testing.assert_array_equal(m.partial_copy_four_rm_r(ref2[:, (0, 2)]), ref2[:, (0, 2)])
50 np.testing.assert_array_equal(
53 np.testing.assert_array_equal(m.partial_copy_four_cm_r(ref2), ref2)
54 np.testing.assert_array_equal(m.partial_copy_four_cm_c(ref2), ref2)
55 np.testing.assert_array_equal(m.partial_copy_four_cm_r(ref2[:, 1]), ref2[:, [1]])
56 np.testing.assert_array_equal(m.partial_copy_four_cm_c(ref2[0, :]), ref2[[0], :])
57 np.testing.assert_array_equal(m.partial_copy_four_cm_r(ref2[:, (0, 2)]), ref2[:, (0, 2)])
58 np.testing.assert_array_equal(
73 zr = np.arange(30, dtype='float32').reshape(5, 6) # row-major
89 m.fixed_mutator_a(np.array([[1, 2], [3, 4]], dtype='float32'))
102 z = np.array([[5., 6], [7, 8]])
123 z = np.full((5, 6), 42.0)
125 np.testing.assert_array_equal(z, m.fixed_copy_r(z))
126 np.testing.assert_array_equal(m.fixed_r_const(), m.fixed_r())
128 np.testing.assert_array_equal(m.fixed_copy_r(m.fixed_r_const()), m.fixed_r_const())
132 counting_mat = np.arange(9.0, dtype=np.float32).reshape((3, 3))
135 np.testing.assert_array_equal(m.double_row(second_row), 2.0 * second_row)
136 np.testing.assert_array_equal(m.double_col(second_row), 2.0 * second_row)
137 np.testing.assert_array_equal(m.double_complex(second_row), 2.0 * second_row)
138 np.testing.assert_array_equal(m.double_row(second_col), 2.0 * second_col)
139 np.testing.assert_array_equal(m.double_col(second_col), 2.0 * second_col)
140 np.testing.assert_array_equal(m.double_complex(second_col), 2.0 * second_col)
142 counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
145 np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
146 np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
151 np.testing.assert_array_equal(counting_mat, [[0., 2, 2], [6, 16, 10], [6, 14, 8]])
159 counting_mat = np.arange(9.0, dtype=np.float32).reshape((3, 3))
163 np.testing.assert_array_equal(m.double_row(second_row), 2.0 * second_row)
164 np.testing.assert_array_equal(m.double_col(second_row), 2.0 * second_row)
165 np.testing.assert_array_equal(m.double_complex(second_row), 2.0 * second_row)
166 np.testing.assert_array_equal(m.double_row(second_col), 2.0 * second_col)
167 np.testing.assert_array_equal(m.double_col(second_col), 2.0 * second_col)
168 np.testing.assert_array_equal(m.double_complex(second_col), 2.0 * second_col)
170 counting_3d = np.arange(27.0, dtype=np.float32).reshape((3, 3, 3))
174 np.testing.assert_array_equal(m.double_mat_cm(ref_mat), 2.0 * ref_mat)
175 np.testing.assert_array_equal(m.double_mat_rm(ref_mat), 2.0 * ref_mat)
184 Invoked with: """ + repr(np.array([ 5., 4., 3.], dtype='float32')) # noqa: E501 line too long
192 Invoked with: """ + repr(np.array([ 7., 4., 1.], dtype='float32')) # noqa: E501 line too long
196 assert np.all(m.diagonal(ref) == ref.diagonal())
197 assert np.all(m.diagonal_1(ref) == ref.diagonal(1))
199 assert np.all(m.diagonal_n(ref, i) == ref.diagonal(i)), "m.diagonal_n({})".format(i)
201 assert np.all(m.block(ref, 2, 1, 3, 3) == ref[2:5, 1:4])
202 assert np.all(m.block(ref, 1, 4, 4, 2) == ref[1:, 4:])
203 assert np.all(m.block(ref, 1, 4, 3, 2) == ref[1:4, 4:])
209 mymat = chol(np.array([[1., 2, 4], [2, 13, 23], [4, 23, 77]]))
210 assert np.all(mymat == np.array([[1, 0, 0], [2, 3, 0], [4, 5, 6]])), "cholesky{}".format(i)
219 z = np.array(a, copy=True)
227 master = np.ones((10, 10))
247 np.testing.assert_array_equal(a_copy1, master)
252 np.testing.assert_array_equal(a_copy2, master)
273 np.testing.assert_array_equal(a_copy3, master)
278 np.testing.assert_array_equal(a_copy4, master)
297 np.testing.assert_array_equal(a_copy5, master[2:4, 2:5])
316 np.testing.assert_array_equal(a_get1, master)
317 np.testing.assert_array_equal(a_get2, master)
318 np.testing.assert_array_equal(a_view1, master)
319 np.testing.assert_array_equal(a_view2, master)
320 np.testing.assert_array_equal(a_ref1, master)
321 np.testing.assert_array_equal(a_ref2, master)
322 np.testing.assert_array_equal(a_ref3, master)
323 np.testing.assert_array_equal(a_ref4, master)
324 np.testing.assert_array_equal(a_block1, master[3:5, 3:5])
325 np.testing.assert_array_equal(a_block2, master[2:5, 2:4])
326 np.testing.assert_array_equal(a_block3, master[6:10, 7:10])
327 np.testing.assert_array_equal(a_corn1, master[0::master.shape[0] - 1, 0::master.shape[1] - 1])
328 np.testing.assert_array_equal(a_corn2, master[0::master.shape[0] - 1, 0::master.shape[1] - 1])
330 np.testing.assert_array_equal(a_copy1, c1want)
331 np.testing.assert_array_equal(a_copy2, c2want)
332 np.testing.assert_array_equal(a_copy3, c3want)
333 np.testing.assert_array_equal(a_copy4, c4want)
334 np.testing.assert_array_equal(a_copy5, c5want)
376 orig = np.array([[1., 2, 3], [4, 5, 6], [7, 8, 9]])
377 zr = np.array(orig)
378 zc = np.array(orig, order='F')
380 assert np.all(zr == np.array([[1., 2, 3], [104, 5, 6], [7, 8, 9]]))
382 assert np.all(zc == np.array([[1., 2, 3], [204, 5, 6], [7, 8, 9]]))
385 assert np.all(zr == np.array([[1., 2, 3], [124, 5, 6], [7, 8, 9]]))
387 assert np.all(zc == np.array([[1., 2, 3], [214, 5, 6], [7, 8, 9]]))
398 assert np.all(zr == orig)
401 assert np.all(zc == orig)
408 assert np.all(cornersr == np.array([[1., 3], [7, 9]]))
409 assert np.all(cornersc == np.array([[1., 3], [7, 9]]))
421 assert np.all(zr == np.array([[1., 2, 28], [4, 5, 6], [7, 8, 9]]))
422 assert np.all(zc == np.array([[1., 2, 47], [4, 5, 6], [7, 8, 9]]))
437 zi = np.array([[1, 2], [3, 4]])
460 expect = np.array([[11., 12, 13], [21, 22, 99], [31, 32, 33]])
462 assert np.all(zc == expect)
463 assert np.all(zcro == expect)
464 assert np.all(m.get_cm_ref() == expect)
467 assert np.all(zr == expect)
468 assert np.all(zrro == expect)
469 assert np.all(m.get_rm_ref() == expect)
479 y1 = np.array(m.get_cm_const_ref())
504 assert np.all(z == z2)
505 assert np.all(z == z3)
506 assert np.all(z == z4)
507 assert np.all(z == z5)
508 expect = np.array([[0., 22, 20], [31, 37, 33], [41, 42, 38]])
509 assert np.all(z == expect)
511 y = np.array(range(100), dtype='float64').reshape(10, 10)
512 y2 = m.incr_matrix_any(y, 10) # np -> eigen -> np
513 y3 = m.incr_matrix_any(y2[0::2, 0::2], -33) # np -> eigen -> np slice -> np -> eigen -> np
519 yexpect = np.array(range(100), dtype='float64').reshape(10, 10)
523 assert np.all(y6 == yexpect[0::4, 0::4])
524 assert np.all(y5 == yexpect[0::4, 0::4])
525 assert np.all(y4 == yexpect[0::4, 0::2])
526 assert np.all(y3 == yexpect[0::2, 0::2])
527 assert np.all(y2 == yexpect)
528 assert np.all(y == yexpect)
534 int_matrix_colmajor = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], order='F')
535 dbl_matrix_colmajor = np.array(int_matrix_colmajor, dtype='double', order='F', copy=True)
536 int_matrix_rowmajor = np.array(int_matrix_colmajor, order='C', copy=True)
537 dbl_matrix_rowmajor = np.array(int_matrix_rowmajor, dtype='double', order='C', copy=True)
583 a = np.full(shape=10, fill_value=8, dtype=np.int8)
591 assert np.all(m.incr_diag(7) == np.diag([1., 2, 3, 4, 5, 6, 7]))
593 asymm = np.array([[ 1., 2, 3, 4],
597 symm_lower = np.array(asymm)
598 symm_upper = np.array(asymm)
604 assert np.all(m.symmetric_lower(asymm) == symm_lower)
605 assert np.all(m.symmetric_upper(asymm) == symm_upper)
624 a = np.array([[1.0, 2], [3, 4], [5, 6]])
625 b = np.ones((2, 1))
627 assert np.all(m.matrix_multiply(a, b) == np.array([[3.], [7], [11]]))
628 assert np.all(m.matrix_multiply(A=a, B=b) == np.array([[3.], [7], [11]]))
629 assert np.all(m.matrix_multiply(B=b, A=a) == np.array([[3.], [7], [11]]))
666 assert np.all(m.iss738_f1(np.array([[1., 2, 3]])) == np.array([[1., 102, 203]]))
667 assert np.all(m.iss738_f1(np.array([[1.], [2], [3]])) == np.array([[1.], [12], [23]]))
669 assert np.all(m.iss738_f2(np.array([[1., 2, 3]])) == np.array([[1., 102, 203]]))
670 assert np.all(m.iss738_f2(np.array([[1.], [2], [3]])) == np.array([[1.], [12], [23]]))
676 assert m.iss1105_row(np.ones((1, 7)))
677 assert m.iss1105_col(np.ones((7, 1)))
681 m.iss1105_row(np.ones((7, 1)))
684 m.iss1105_col(np.ones((1, 7)))
693 np.testing.assert_allclose(o.a, 0.0)
694 np.testing.assert_allclose(o.b.diagonal(), 1.0)