Пример #1
0
        def _test_numpy(dtype_name, nchannels, order='c'):
            np_img = create_numpy_image(dtype_name, nchannels, order)
            img_container = ImageContainer(Image(np_img))
            recast = img_container.asarray()

            # asarray always returns 3 channels
            np_img = np.atleast_3d(np_img)

            vital_img = img_container.image()
            pixel_type_name = vital_img.pixel_type_name()

            pixel_type_name = vital_img.pixel_type_name()
            want = map_dtype_name_to_pixel_type(dtype_name)

            assert pixel_type_name == want, 'want={} but got={}'.format(
                want, pixel_type_name)

            if not np.all(np_img == recast):
                raise AssertionError(
                    'Failed dtype={}, nchannels={}, order={}'.format(
                        dtype_name, nchannels, order))