Ejemplo n.º 1
0
 def test_exotic_formats(self):
     # Test that 'exotic' formats are processed properly
     easy = mrecarray(1, dtype=[("i", int), ("s", "|S8"), ("f", float)])
     easy[0] = masked
     assert_equal(easy.filled(1).item(), (1, asbytes("1"), 1.0))
     #
     solo = mrecarray(1, dtype=[("f0", "<f8", (2, 2))])
     solo[0] = masked
     assert_equal(solo.filled(1).item(), np.array((1,), dtype=solo.dtype).item())
     #
     mult = mrecarray(2, dtype="i4, (2,3)float, float")
     mult[0] = masked
     mult[1] = (1, 1, 1)
     mult.filled(0)
     assert_equal_records(mult.filled(0), np.array([(0, 0, 0), (1, 1, 1)], dtype=mult.dtype))
Ejemplo n.º 2
0
 def test_exotic_formats(self):
     "Test that 'exotic' formats are processed properly"
     easy = mrecarray(1, dtype=[('i',int), ('s','|S8'), ('f',float)])
     easy[0] = masked
     assert_equal(easy.filled(1).item(), (1,asbytes('1'),1.))
     #
     solo = mrecarray(1, dtype=[('f0', '<f8', (2, 2))])
     solo[0] = masked
     assert_equal(solo.filled(1).item(),
                  np.array((1,), dtype=solo.dtype).item())
     #
     mult = mrecarray(2, dtype= "i4, (2,3)float, float")
     mult[0] = masked
     mult[1] = (1, 1, 1)
     mult.filled(0)
     assert_equal_records(mult.filled(0),
                          np.array([(0,0,0),(1,1,1)], dtype=mult.dtype))
Ejemplo n.º 3
0
    def test_exotic_formats(self):
        # Test that 'exotic' formats are processed properly
        easy = mrecarray(1, dtype=[("i", int), ("s", "|S8"), ("f", float)])
        easy[0] = masked
        assert_equal(easy.filled(1).item(), (1, b"1", 1.0))

        solo = mrecarray(1, dtype=[("f0", "<f8", (2, 2))])
        solo[0] = masked
        assert_equal(solo.filled(1).item(), np.array((1,), dtype=solo.dtype).item())

        mult = mrecarray(2, dtype="i4, (2,3)float, float")
        mult[0] = masked
        mult[1] = (1, 1, 1)
        mult.filled(0)
        assert_equal_records(
            mult.filled(0), np.array([(0, 0, 0), (1, 1, 1)], dtype=mult.dtype)
        )
Ejemplo n.º 4
0
 def test_withnames(self):
     "Test the creation w/ format and names"
     x = mrecarray(1, formats=float, names='base')
     x[0]['base'] = 10
     assert_equal(x['base'][0], 10)
Ejemplo n.º 5
0
 def test_withnames(self):
     # Test the creation w/ format and names
     x = mrecarray(1, formats=float, names='base')
     x[0]['base'] = 10
     assert_equal(x['base'][0], 10)
Ejemplo n.º 6
0
 def test_withnames(self):
     "Test the creation w/ format and names"
     x = mrecarray(1, formats=float, names="base")
     x[0]["base"] = 10
     assert_equal(x["base"][0], 10)
Ejemplo n.º 7
0
 def test_withnames(self):
     # Test the creation w/ format and names
     x = mrecarray(1, formats=float, names="base")
     x[0]["base"] = 10
     assert_equal(x["base"][0], 10)