Skip to content

Commit

Permalink
Update MPIBlockVector testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Nov 7, 2024
1 parent 2f6e7d6 commit a2f27b2
Showing 1 changed file with 18 additions and 61 deletions.
79 changes: 18 additions & 61 deletions pyomo/contrib/pynumero/sparse/tests/test_mpi_block_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,48 +1403,13 @@ def test_unary_ufuncs(self):
bv.set_block(0, a)
bv.set_block(1, b)

unary_funcs = [
np.log10,
np.sin,
np.cos,
np.exp,
np.ceil,
np.floor,
np.tan,
np.arctan,
np.arcsin,
np.arccos,
np.sinh,
np.cosh,
np.abs,
np.tanh,
np.arcsinh,
np.arctanh,
np.fabs,
np.sqrt,
np.log,
np.log2,
np.absolute,
np.isfinite,
np.isinf,
np.isnan,
np.log1p,
np.logical_not,
np.exp2,
np.expm1,
np.sign,
np.rint,
np.square,
np.positive,
np.negative,
np.rad2deg,
np.deg2rad,
np.conjugate,
np.reciprocal,
]
_int_ufuncs = {np.invert, np.arccosh}

bv2 = BlockVector(2)
for fun in unary_funcs:
if fun in _int_ufuncs:
continue

bv2.set_block(0, fun(bv.get_block(0)))
bv2.set_block(1, fun(bv.get_block(1)))
res = fun(v)
Expand All @@ -1454,7 +1419,7 @@ def test_unary_ufuncs(self):
self.assertTrue(np.allclose(res.get_block(i), bv2.get_block(i)))

with self.assertRaises(Exception) as context:
np.cbrt(v)
np.modf(v)

with self.assertRaises(Exception) as context:
np.cumsum(v)
Expand Down Expand Up @@ -1504,29 +1469,21 @@ def test_binary_ufuncs(self):
bv2.set_block(0, np.ones(3) * 3.0)
bv2.set_block(1, np.ones(2) * 2.8)

binary_ufuncs = [
np.add,
np.multiply,
np.divide,
np.subtract,
np.greater,
np.greater_equal,
np.less,
np.less_equal,
np.not_equal,
np.maximum,
np.minimum,
np.fmax,
np.fmin,
np.equal,
np.logaddexp,
np.logaddexp2,
np.remainder,
np.heaviside,
np.hypot,
]
_int_ufuncs = {
np.gcd,
np.lcm,
np.ldexp,
np.left_shift,
np.right_shift,
np.bitwise_and,
np.bitwise_or,
np.bitwise_xor,
}

for fun in binary_ufuncs:
if fun in _int_ufuncs:
continue

serial_res = fun(bv, bv2)
res = fun(v, v2)

Expand Down

0 comments on commit a2f27b2

Please sign in to comment.