def test_basic_roundtrip(self): data = numpy.random.randint(0,255, (3, 100, 200)).astype(numpy.uint8) codec = VoxelsNddataCodec( data.dtype ) stream = StringIO.StringIO() codec.encode_from_ndarray(stream, data) stream.seek(0) roundtrip_data = codec.decode_to_ndarray(stream, data.shape) assert roundtrip_data.flags['F_CONTIGUOUS'] self._assert_matching(roundtrip_data, data)
def test_basic_roundtrip(self): data = numpy.random.randint(0, 255, (3, 100, 200)).astype(numpy.uint8) codec = VoxelsNddataCodec(data.dtype) stream = StringIO.StringIO() codec.encode_from_ndarray(stream, data) stream.seek(0) roundtrip_data = codec.decode_to_ndarray(stream, data.shape) assert roundtrip_data.flags['F_CONTIGUOUS'] self._assert_matching(roundtrip_data, data)
def test_all_dtypes(self): for dtype in [numpy.uint8, numpy.uint16, numpy.uint32, numpy.float32, numpy.float64]: data = numpy.random.randint(0,255, (3,100,200)).astype(dtype) codec = VoxelsNddataCodec( data.dtype ) stream = StringIO.StringIO() codec.encode_from_ndarray(stream, data) stream.seek(0) roundtrip_data = codec.decode_to_ndarray(stream, data.shape) assert roundtrip_data.flags['F_CONTIGUOUS'] self._assert_matching(roundtrip_data, data)
def test_all_dtypes(self): for dtype in [ numpy.uint8, numpy.uint16, numpy.uint32, numpy.float32, numpy.float64 ]: data = numpy.random.randint(0, 255, (3, 100, 200)).astype(dtype) codec = VoxelsNddataCodec(data.dtype) stream = StringIO.StringIO() codec.encode_from_ndarray(stream, data) stream.seek(0) roundtrip_data = codec.decode_to_ndarray(stream, data.shape) assert roundtrip_data.flags['F_CONTIGUOUS'] self._assert_matching(roundtrip_data, data)