def test_equal(self): x = self.q.magnitude u = self.Q_(np.ones(x.shape)) true = np.ones_like(x, dtype=np.bool_) false = np.zeros_like(x, dtype=np.bool_) self.assertQuantityEqual(u, u) self.assertQuantityEqual(u == u, u.magnitude == u.magnitude) self.assertQuantityEqual(u == 1, u.magnitude == 1) v = self.Q_(np.zeros(x.shape), "m") w = self.Q_(np.ones(x.shape), "m") self.assertNDArrayEqual(v == 1, false) self.assertNDArrayEqual( self.Q_(np.zeros_like(x), "m") == self.Q_(np.zeros_like(x), "s"), false, ) self.assertNDArrayEqual(v == v, true) self.assertNDArrayEqual(v == w, false) self.assertNDArrayEqual(v == w.to("mm"), false) self.assertNDArrayEqual(u == v, false)
def test_zeros_like(self): self.assertNDArrayEqual(np.zeros_like(self.q), np.array([[0, 0], [0, 0]]))