diff --git a/mpmath/ctx_iv.py b/mpmath/ctx_iv.py index 6c1f8857..4b0952b2 100644 --- a/mpmath/ctx_iv.py +++ b/mpmath/ctx_iv.py @@ -252,41 +252,28 @@ def _binary_op(f_real, f_complex): return g_complex(ctx, sval, tval) def lop_real(s, t): ctx = s.ctx - if not isinstance(t, ctx._types): - try: - t = ctx.convert(t) - except (ValueError, TypeError): - return NotImplemented + if not isinstance(t, ctx._types): t = ctx.convert(t) if hasattr(t, "_mpi_"): return g_real(ctx, s._mpi_, t._mpi_) - if hasattr(t, "_mpci_"): - return g_complex(ctx, (s._mpi_, mpi_zero), t._mpci_) + if hasattr(t, "_mpci_"): return g_complex(ctx, (s._mpi_, mpi_zero), t._mpci_) return NotImplemented def rop_real(s, t): ctx = s.ctx - if not isinstance(t, ctx._types): - try: - t = ctx.convert(t) - except (ValueError, TypeError): - return NotImplemented + if not isinstance(t, ctx._types): t = ctx.convert(t) if hasattr(t, "_mpi_"): return g_real(ctx, t._mpi_, s._mpi_) - if hasattr(t, "_mpci_"): - return g_complex(ctx, t._mpci_, (s._mpi_, mpi_zero)) + if hasattr(t, "_mpci_"): return g_complex(ctx, t._mpci_, (s._mpi_, mpi_zero)) return NotImplemented def lop_complex(s, t): ctx = s.ctx - if not isinstance(t, ctx._types): + if not isinstance(t, s.ctx._types): try: - t = ctx.convert(t) + t = s.ctx.convert(t) except (ValueError, TypeError): return NotImplemented return g_complex(ctx, s._mpci_, t._mpci_) def rop_complex(s, t): ctx = s.ctx - if not isinstance(t, ctx._types): - try: - t = ctx.convert(t) - except (ValueError, TypeError): - return NotImplemented + if not isinstance(t, s.ctx._types): + t = s.ctx.convert(t) return g_complex(ctx, t._mpci_, s._mpci_) return lop_real, rop_real, lop_complex, rop_complex diff --git a/mpmath/tests/test_matrices.py b/mpmath/tests/test_matrices.py index 0b5bd8fe..25fdd697 100644 --- a/mpmath/tests/test_matrices.py +++ b/mpmath/tests/test_matrices.py @@ -178,9 +178,3 @@ def test_matrix_numpy(): l = [[1, 2], [3, 4], [5, 6]] a = numpy.array(l) assert matrix(l) == matrix(a) - -def test_matrix_iv(): - A = iv.matrix([[1, 2], [3, 4]]) - two = iv.mpf(2) - assert A*two == two*A - assert two*A == iv.matrix([[iv.mpf(2), iv.mpf(4)], [iv.mpf(6), iv.mpf(8)]])