Esempio n. 1
0
 def test_divmod(self):
     """Checks the __divmod__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 1, 1], bla=2, bli='hoj')
     c = divmod(a, b)
     self.assertDictEqual(c[0].info, {'bla': 2})
     self.assertDictEqual(c[1].info, {'bla': 2})
     c = divmod(a, 1)
     self.assertDictEqual(c[0].info, a.info)
     self.assertDictEqual(c[1].info, a.info)
     c = divmod(1, a)
     self.assertDictEqual(c[0].info, a.info)
     self.assertDictEqual(c[1].info, a.info)
Esempio n. 2
0
 def test_mul(self):
     """Checks the __mul__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 0, 0], bla=2, bli='hoj')
     c = a * b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a * 1
     self.assertDictEqual(c.info, a.info)
     c = 1 * a
     self.assertDictEqual(c.info, a.info)
     a *= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b *= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 3
0
 def test_sub(self):
     """Checks the __sub__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 0, 0], bla=2, bli='hoj')
     c = a - b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a - 1
     self.assertDictEqual(c.info, a.info)
     c = 1 - a
     self.assertDictEqual(c.info, a.info)
     a -= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b -= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 4
0
 def test_add(self):
     """Checks the __add__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 0, 0], bla=2, bli='hoj')
     c = a + b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a + 1
     self.assertDictEqual(c.info, a.info)
     c = 1 + a
     self.assertDictEqual(c.info, a.info)
     a += b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b += 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 5
0
 def test_truediv(self):
     """Checks the __truediv__ function.
     """
     a = projectable.Dataset([7., 3., 1.], bla=2, blu='hej')
     b = projectable.Dataset([2., 1., 1.], bla=2, bli='hoj')
     c = a.__truediv__(b)
     self.assertDictEqual(c.info, {'bla': 2})
     c = a.__truediv__(1)
     self.assertDictEqual(c.info, a.info)
     c = a.__rtruediv__(1)
     self.assertDictEqual(c.info, a.info)
     a = a.__itruediv__(b)
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b = b.__itruediv__(1)
     self.assertDictEqual(b.info, b_info)
Esempio n. 6
0
 def test_or(self):
     """Checks the __or__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 1, 1], bla=2, bli='hoj')
     c = a | b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a | 1
     self.assertDictEqual(c.info, a.info)
     c = 1 | a
     self.assertDictEqual(c.info, a.info)
     a |= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b |= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 7
0
 def test_and(self):
     """Checks the __and__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 1, 1], bla=2, bli='hoj')
     c = a & b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a & 1
     self.assertDictEqual(c.info, a.info)
     c = 1 & a
     self.assertDictEqual(c.info, a.info)
     a &= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b &= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 8
0
 def test_rshift(self):
     """Checks the __rshift__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 1, 1], bla=2, bli='hoj')
     c = a >> b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a >> 1
     self.assertDictEqual(c.info, a.info)
     c = 1 >> a
     self.assertDictEqual(c.info, a.info)
     a >>= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b >>= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 9
0
 def test_floordiv(self):
     """Checks the __floordiv__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     b = projectable.Dataset([2, 1, 1], bla=2, bli='hoj')
     c = a // b
     self.assertDictEqual(c.info, {'bla': 2})
     c = a // 1
     self.assertDictEqual(c.info, a.info)
     c = 1 // a
     self.assertDictEqual(c.info, a.info)
     a //= b
     self.assertDictEqual(a.info, {'bla': 2})
     b_info = b.info.copy()
     b //= 1
     self.assertDictEqual(b.info, b_info)
Esempio n. 10
0
 def test_copy(self):
     """
     Test copying a dataset
     """
     ds = projectable.Dataset(np.arange(8), foo="bar")
     ds_copy = ds.copy()
     self.assertTrue(ds_copy.data is not ds.data
                     and all(ds.data == ds_copy.data))
     if sys.version >= "2.7":
         self.assertDictEqual(ds.info, ds_copy.info)
Esempio n. 11
0
 def test_str_repr(self):
     ds = projectable.Dataset(np.arange(1, 25), foo="bar")
     ds_str = str(ds)
     ds_repr = repr(ds)
Esempio n. 12
0
 def test_invert(self):
     """Checks the __invert__ function.
     """
     a = projectable.Dataset([7, 3, 1], bla=2, blu='hej')
     c = ~a
     self.assertDictEqual(c.info, a.info)