hexa | python3.13-keras> =================================== FAILURES ===================================
python3.13-keras> __________________ NumpyTwoInputOpsCorrectnessTest.test_cross __________________
python3.13-keras>
python3.13-keras> self = <keras.src.ops.numpy_test.NumpyTwoInputOpsCorrectnessTest testMethod=test_cross>
python3.13-keras>
python3.13-keras> def test_cross(self):
python3.13-keras> x1 = np.ones([2, 1, 4, 3])
python3.13-keras> x2 = np.ones([2, 1, 4, 2])
python3.13-keras> y1 = np.ones([2, 1, 4, 3])
python3.13-keras> y2 = np.ones([1, 5, 4, 3])
python3.13-keras> y3 = np.ones([1, 5, 4, 2])
python3.13-keras> self.assertAllClose(knp.cross(x1, y1), np.cross(x1, y1))
python3.13-keras> self.assertAllClose(knp.cross(x1, y2), np.cross(x1, y2))
python3.13-keras> if backend.backend() != "torch":
python3.13-keras> # API divergence between `torch.cross` and `np.cross`
python3.13-keras> # `torch.cross` only allows dim 3, `np.cross` allows dim 2 or 3
python3.13-keras> > self.assertAllClose(knp.cross(x1, y3), np.cross(x1, y3))
python3.13-keras> ^^^^^^^^^^^^^^^^
python3.13-keras>
python3.13-keras> keras/src/ops/numpy_test.py:3659:
python3.13-keras> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.13-keras>
python3.13-keras> a = array([[[[1., 1., 1.],
python3.13-keras> [1., 1., 1.],
python3.13-keras> [1., 1., 1.],
python3.13-keras> [1., 1., 1.]]],
python3.13-keras>
python3.13-keras>
python3.13-keras> [[[1., 1., 1.],
python3.13-keras> [1., 1., 1.],
python3.13-keras> [1., 1., 1.],
python3.13-keras> [1., 1., 1.]]]])
python3.13-keras> b = array([[[[1., 1.],
python3.13-keras> [1., 1.],
python3.13-keras> [1., 1.],
python3.13-keras> [1., 1.]],
python3.13-keras>
python3.13-keras> [[1., 1.],
python3.13-keras> [1., 1.],
python3.13-keras> ...
python3.13-keras> [1., 1.],
python3.13-keras> [1., 1.]],
python3.13-keras>
python3.13-keras> [[1., 1.],
python3.13-keras> [1., 1.],
python3.13-keras> [1., 1.],
python3.13-keras> [1., 1.]]]])
python3.13-keras> axisa = 3, axisb = 3, axisc = -1, axis = None
python3.13-keras>
python3.13-keras> @array_function_dispatch(_cross_dispatcher)
python3.13-keras> def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None):
python3.13-keras> """
python3.13-keras> Return the cross product of two (arrays of) vectors.
python3.13-keras>
python3.13-keras> The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
python3.13-keras> to both `a` and `b`. If `a` and `b` are arrays of vectors, the vectors
python3.13-keras> are defined by the last axis of `a` and `b` by default, and these axes
python3.13-keras> must have 3 dimensions.
python3.13-keras>
python3.13-keras> Parameters
python3.13-keras> ----------
python3.13-keras> a : array_like
python3.13-keras> Components of the first vector(s).
python3.13-keras> b : array_like
python3.13-keras> Components of the second vector(s).
python3.13-keras> axisa : int, optional
python3.13-keras> Axis of `a` that defines the vector(s). By default, the last axis.
python3.13-keras> axisb : int, optional
python3.13-keras> Axis of `b` that defines the vector(s). By default, the last axis.
python3.13-keras> axisc : int, optional
python3.13-keras> Axis of `c` containing the cross product vector(s). By default, the last axis.
python3.13-keras> axis : int, optional
python3.13-keras> If defined, the axis of `a`, `b` and `c` that defines the vector(s)
python3.13-keras> and cross product(s). Overrides `axisa`, `axisb` and `axisc`.
python3.13-keras>
python3.13-keras> Returns
python3.13-keras> -------
python3.13-keras> c : ndarray
python3.13-keras> Vector cross product(s).
python3.13-keras>
python3.13-keras> Raises
python3.13-keras> ------
python3.13-keras> ValueError
python3.13-keras> When the dimension of the vector(s) in `a` or `b` does not equal 3.
python3.13-keras>
python3.13-keras> See Also
python3.13-keras> --------
python3.13-keras> inner : Inner product
python3.13-keras> outer : Outer product.
python3.13-keras> linalg.cross : An Array API compatible variation of ``np.cross``.
python3.13-keras> ix_ : Construct index arrays.
python3.13-keras>
python3.13-keras> Notes
python3.13-keras> -----
python3.13-keras> Supports full broadcasting of the inputs.
python3.13-keras>
python3.13-keras> Examples
python3.13-keras> --------
python3.13-keras> Vector cross-product.
python3.13-keras>
python3.13-keras> >>> import numpy as np
python3.13-keras> >>> x = [1, 2, 3]
python3.13-keras> >>> y = [4, 5, 6]
python3.13-keras> >>> np.cross(x, y)
python3.13-keras> array([-3, 6, -3])
python3.13-keras>
python3.13-keras> One vector with dimension 2.
python3.13-keras>
python3.13-keras> >>> x = [1, 2, 0]
python3.13-keras> >>> y = [4, 5, 6]
python3.13-keras> >>> np.cross(x, y)
python3.13-keras> array([12, -6, -3])
python3.13-keras>
python3.13-keras> Both vectors with dimension 2.
python3.13-keras>
python3.13-keras> >>> x = [1, 2, 0]
python3.13-keras> >>> y = [4, 5, 0]
python3.13-keras> >>> np.cross(x, y)
python3.13-keras> array([0, 0, -3])
python3.13-keras>
python3.13-keras> Multiple vector cross-products. Note that the direction of the cross
python3.13-keras> product vector is defined by the *right-hand rule*.
python3.13-keras>
python3.13-keras> >>> x = np.array([[1,2,3], [4,5,6]])
python3.13-keras> >>> y = np.array([[4,5,6], [1,2,3]])
python3.13-keras> >>> np.cross(x, y)
python3.13-keras> array([[-3, 6, -3],
python3.13-keras> [ 3, -6, 3]])
python3.13-keras>
python3.13-keras> The orientation of `c` can be changed using the `axisc` keyword.
python3.13-keras>
python3.13-keras> >>> np.cross(x, y, axisc=0)
python3.13-keras> array([[-3, 3],
python3.13-keras> [ 6, -6],
python3.13-keras> [-3, 3]])
python3.13-keras>
python3.13-keras> Change the vector definition of `x` and `y` using `axisa` and `axisb`.
python3.13-keras>
python3.13-keras> >>> x = np.array([[1,2,3], [4,5,6], [7, 8, 9]])
python3.13-keras> >>> y = np.array([[7, 8, 9], [4,5,6], [1,2,3]])
python3.13-keras> >>> np.cross(x, y)
python3.13-keras> array([[ -6, 12, -6],
python3.13-keras> [ 0, 0, 0],
python3.13-keras> [ 6, -12, 6]])
python3.13-keras> >>> np.cross(x, y, axisa=0, axisb=0)
python3.13-keras> array([[-24, 48, -24],
python3.13-keras> [-30, 60, -30],
python3.13-keras> [-36, 72, -36]])
python3.13-keras>
python3.13-keras> """
python3.13-keras> if axis is not None:
python3.13-keras> axisa, axisb, axisc = (axis,) * 3
python3.13-keras> a = asarray(a)
python3.13-keras> b = asarray(b)
python3.13-keras>
python3.13-keras> if (a.ndim < 1) or (b.ndim < 1):
python3.13-keras> raise ValueError("At least one array has zero dimension")
python3.13-keras>
python3.13-keras> # Check axisa and axisb are within bounds
python3.13-keras> axisa = normalize_axis_index(axisa, a.ndim, msg_prefix='axisa')
python3.13-keras> axisb = normalize_axis_index(axisb, b.ndim, msg_prefix='axisb')
python3.13-keras>
python3.13-keras> # Move working axis to the end of the shape
python3.13-keras> a = moveaxis(a, axisa, -1)
python3.13-keras> b = moveaxis(b, axisb, -1)
python3.13-keras> if a.shape[-1] != 3 or b.shape[-1] != 3:
python3.13-keras> > raise ValueError(
python3.13-keras> f"Both input arrays must be (arrays of) 3-dimensional vectors, "
python3.13-keras> f"but they are {a.shape[-1]} and {b.shape[-1]} dimensional instead."
python3.13-keras> )
python3.13-keras> E ValueError: Both input arrays must be (arrays of) 3-dimensional vectors, but they are 3 and 2 dimensional instead.
python3.13-keras>
python3.13-keras> /nix/store/i4ajph3w20gpspwsmhaqkbgj8mkjlr4n-python3.13-numpy-2.5.0/lib/python3.13/site-packages/numpy/_core/numeric.py:1679: ValueError
python3.13-keras> =========================== short test summary info ============================
python3.13-keras> FAILED keras/src/ops/numpy_test.py::NumpyTwoInputOpsCorrectnessTest::test_cross - ValueError: Both input arrays must be (arrays of) 3-dimensional vectors, but they are 3 and 2 dimensional instead.
python3.13-keras> = 1 failed, 12630 passed, 482 skipped, 33 deselected, 7 xfailed, 6 xpassed, 4 subtests passed in 1702.65s (0:28:22) =
| 22:37:09 |