Ejemplo n.º 1
0
    def setUp(self):
        self.shape = Shape("3x4x5")
        self.l0 = cb.linear_cube(self.shape, start=0.5, increment=1.5)
        self.l1 = cb.linear_cube(self.shape, start=0.5, increment=0.5)
        self.l2 = cb.linear_cube(self.shape, start=-1.0, increment=0.5)

        self.epsilon = 1.0e-8
        e = self.epsilon
        self.c0 = np.array([0.0, 0.0, e, 1.0, 1.0 + e, 1.0], )
        self.c1 = np.array([0.0, e, 0.0, 1.0, 1.0, 1.0 + e])
Ejemplo n.º 2
0
    def setUp(self):
        self.shape = Shape("3x4x5")
        self.l0 = cb.linear_cube(self.shape, start=0.5, increment=1.5)
        self.l1 = cb.linear_cube(self.shape, start=0.5, increment=0.5)
        self.l2 = cb.linear_cube(self.shape, start=-1.0, increment=0.5)

        self.epsilon = 1.0e-8
        e = self.epsilon
        self.c0 = np.array([0.0, 0.0, e, 1.0, 1.0 + e, 1.0])
        self.c1 = np.array([0.0, e, 0.0, 1.0, 1.0, 1.0 + e])
Ejemplo n.º 3
0
 def join3(self):
     cube0 = cb.const_cube(shape="3x5", value=1.5)
     cube1 = cb.linear_cube(shape="3x5", start=1.5, increment=0.5)
     cube2 = cb.const_cube(shape="3x5", value=-1.5)
     cubes = (cube0, cube1, cube2)
     result = np.array(cubes)
     return self.impl_join(cubes, result)
Ejemplo n.º 4
0
 def join3(self):
     cube0 = cb.const_cube(shape="3x5", value=1.5)
     cube1 = cb.linear_cube(shape="3x5", start=1.5, increment=0.5)
     cube2 = cb.const_cube(shape="3x5", value=-1.5)
     cubes = (cube0, cube1, cube2)
     result = np.array(cubes)
     return self.impl_join(cubes, result)
Ejemplo n.º 5
0
    def create_linear_cubes(self, shape, dtype):
        cube_l = cb.linear_cube(shape=shape, dtype=dtype)
        cube_r = cube_l * 1.5
        dmin = 2
        for d in shape:
            assert d >= dmin, "d={} < {}".format(d, dmin)
        index_diff_0 = tuple(0 for i in shape)
        index_diff_1 = tuple(1 for i in shape)
        cube_r[index_diff_0] = cube_l[index_diff_0] * 0.1
        cube_r[index_diff_1] = cube_l[index_diff_1] * 10.3

        return cube_l, cube_r
Ejemplo n.º 6
0
    def impl_read_write(self, shape, dtype, file_format):
        dtype = cb.get_dtype(dtype)
        shape = Shape(shape)

        out0_filename_format = "o0tmp_{shape}_{dtype}.{format}"
        out0_filename = out0_filename_format.format(shape=shape,
                                                    dtype=dtype.__name__,
                                                    format='raw')

        out1_filename_format = "o1tmp_{shape}_{dtype}.{format}"
        out1_filename = out1_filename_format.format(shape=shape,
                                                    dtype=dtype.__name__,
                                                    format=file_format)

        out2_filename_format = "o2tmp_{shape}_{dtype}.{format}"
        out2_filename = out2_filename_format.format(shape=shape,
                                                    dtype=dtype.__name__,
                                                    format='raw')

        cube = cb.linear_cube(shape=shape, dtype=dtype)
        cb.write_cube_raw(cube=cube, file=out0_filename_format)
        self.assertFileExistsAndHasShape(out0_filename, shape, dtype=dtype)

        returncode, output, error = self.run_program(
            """-i '{i}' -It '{t}' -s '{s}' -e 'write_cube(cube=_r, filename="{o}", format="{f}", dtype="{t}")'"""
            .format(i=out0_filename_format,
                    s=shape,
                    o=out1_filename_format,
                    f=file_format,
                    t=dtype.__name__))

        self.assertFileExists(out1_filename)

        returncode, output, error = self.run_program(
            """-e 'read_cube(shape="{s}", filename="{i}", format="{f}", dtype="{t}")' -e 'write_cube(cube=_r, filename="{o}", format="raw", dtype="{t}")'"""
            .format(i=out1_filename_format,
                    s=shape,
                    o=out2_filename_format,
                    f=file_format,
                    t=dtype.__name__))

        self.assertFileExistsAndHasShape(out2_filename, shape, dtype=dtype)
        self.assertFilesAreEqual(out0_filename, out2_filename)
        self.remove_files(out0_filename, out1_filename, out2_filename)
Ejemplo n.º 7
0
    def impl_read_write(self, shape, dtype, file_format):
        dtype = cb.get_dtype(dtype)
        shape = Shape(shape)

        out0_filename_format = "o0tmp_{shape}_{dtype}.{format}"
        out0_filename = out0_filename_format.format(shape=shape, dtype=dtype.__name__, format='raw')
        
        out1_filename_format = "o1tmp_{shape}_{dtype}.{format}"
        out1_filename = out1_filename_format.format(shape=shape, dtype=dtype.__name__, format=file_format)
        
        out2_filename_format = "o2tmp_{shape}_{dtype}.{format}"
        out2_filename = out2_filename_format.format(shape=shape, dtype=dtype.__name__, format='raw')
        
        cube = cb.linear_cube(shape=shape, dtype=dtype)
        cb.write_cube_raw(cube=cube, file=out0_filename_format)
        self.assertFileExistsAndHasShape(out0_filename, shape, dtype=dtype)

        returncode, output, error = self.run_program(
            """-i '{i}' -It '{t}' -s '{s}' -e 'write_cube(cube=_r, filename="{o}", format="{f}", dtype="{t}")'""".format(
                i=out0_filename_format,
                s=shape,
                o=out1_filename_format,
                f=file_format,
                t=dtype.__name__))

        self.assertFileExists(out1_filename)

        returncode, output, error = self.run_program(
            """-e 'read_cube(shape="{s}", filename="{i}", format="{f}", dtype="{t}")' -e 'write_cube(cube=_r, filename="{o}", format="raw", dtype="{t}")'""".format(
                i=out1_filename_format,
                s=shape,
                o=out2_filename_format,
                f=file_format,
                t=dtype.__name__))

        self.assertFileExistsAndHasShape(out2_filename, shape, dtype=dtype)
        self.assertFilesAreEqual(out0_filename, out2_filename)
        self.remove_files(out0_filename, out1_filename, out2_filename)