def test_truediv_scalar(scalar, device, shape, numeric_dtype): x_np = array_utils.create_dummy_ndarray(numpy, shape, numeric_dtype) expected = x_np / scalar x = chainerx.array(x_np) scalar_chx = chainerx.Scalar(scalar) chainerx.testing.assert_array_equal_ex( x / scalar, expected, strides_check=False) chainerx.testing.assert_array_equal_ex( x / scalar_chx, expected, strides_check=False) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar), expected, strides_check=False) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar_chx), expected, strides_check=False)
def test_truediv_scalar(scalar, device, shape, numeric_dtype): x_np = array_utils.create_dummy_ndarray(numpy, shape, numeric_dtype) expected = x_np / scalar x = chainerx.array(x_np) scalar_chx = chainerx.Scalar(scalar, numeric_dtype) chainerx.testing.assert_array_equal_ex( x / scalar, expected, strides_check=False) chainerx.testing.assert_array_equal_ex( x / scalar_chx, expected, strides_check=False) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar), expected, strides_check=False) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar_chx), expected, strides_check=False)
def test_truediv_scalar(scalar, device, shape, numeric_dtype): x_np = array_utils.create_dummy_ndarray(numpy, shape, numeric_dtype) if 'int' in numeric_dtype: # NumPy does not support itruediv to integer arrays. expected = (x_np / scalar).astype(numeric_dtype) else: expected = x_np / scalar x = chainerx.array(x_np) scalar_chx = chainerx.Scalar(scalar, numeric_dtype) chainerx.testing.assert_array_equal_ex(x / scalar, expected) chainerx.testing.assert_array_equal_ex(x / scalar_chx, expected) chainerx.testing.assert_array_equal_ex(chainerx.divide(x, scalar), expected) chainerx.testing.assert_array_equal_ex(chainerx.divide(x, scalar_chx), expected)
def test_truediv_scalar(scalar, device, shape, numeric_dtype): x_np = array_utils.create_dummy_ndarray(numpy, shape, numeric_dtype) if 'int' in numeric_dtype: # NumPy does not support itruediv to integer arrays. expected = (x_np / scalar).astype(numeric_dtype) else: expected = x_np / scalar x = chainerx.array(x_np) scalar_chx = chainerx.Scalar(scalar, numeric_dtype) chainerx.testing.assert_array_equal_ex(x / scalar, expected) chainerx.testing.assert_array_equal_ex(x / scalar_chx, expected) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar), expected) chainerx.testing.assert_array_equal_ex( chainerx.divide(x, scalar_chx), expected)