示例#1
0
 def check(self, dtype, word_size=None):
     if word_size is None:
         header = FixedLengthHeader.empty()
     else:
         header = FixedLengthHeader.empty(word_size)
     self.assertArrayEqual(header.raw, [-32768] * 256)
     self.assertEqual(header.raw.dtype, dtype)
示例#2
0
 def check(self, src_dtype, word_size=None):
     data = (np.arange(1000) * 10).astype(src_dtype)
     with self.temp_filename() as filename:
         data.tofile(filename)
         with open(filename, "rb") as source:
             if word_size is None:
                 header = FixedLengthHeader.from_file(source)
             else:
                 header = FixedLengthHeader.from_file(source, word_size)
     self.assertArrayEqual(header.raw, np.arange(256) * 10)
示例#3
0
 def test_equal(self):
     ffv1 = FixedLengthHeader(list(range(256)))
     ffv2 = FixedLengthHeader(np.arange(256))
     self.assertFalse(ffv1.__ne__(ffv2))
示例#4
0
 def test_invalid(self):
     ffv1 = FixedLengthHeader(list(range(256)))
     self.assertIs(ffv1.__eq__(np.arange(256)), NotImplemented)
示例#5
0
 def test_equal(self):
     ffv1 = FixedLengthHeader(range(256))
     ffv2 = FixedLengthHeader(range(256))
     self.assertTrue(ffv1.__eq__(ffv2))
示例#6
0
 def test_not_equal(self):
     ffv1 = FixedLengthHeader(range(256))
     ffv2 = FixedLengthHeader(range(256, 512))
     self.assertFalse(ffv1.__eq__(ffv2))
示例#7
0
 def test_invalid(self):
     ffv1 = FixedLengthHeader(range(256))
     self.assertIs(ffv1.__ne__(range(256)), NotImplemented)
示例#8
0
 def test_not_equal(self):
     ffv1 = FixedLengthHeader(list(range(256)))
     ffv2 = FixedLengthHeader(np.arange(256, 512))
     self.assertFalse(ffv1.__eq__(ffv2))
示例#9
0
 def test_invalid_length(self):
     with self.assertRaisesRegexp(ValueError, 'Incorrect number of words'):
         FixedLengthHeader(list(range(15)))
示例#10
0
def make_header():
    return FixedLengthHeader((np.arange(256) + 1) * 10)
示例#11
0
 def test_invalid(self):
     ffv1 = FixedLengthHeader(list(range(256)))
     self.assertIs(ffv1.__ne__(np.arange(256)), NotImplemented)