コード例 #1
0
 def impl_write_read_cube_file_format(self, file_format, cube,
                                      filename_format):
     cube_w = cube
     cb.write_cube(file_format=file_format,
                   cube=cube_w,
                   file=filename_format)
     cube_r = cb.read_cube(file_format=file_format,
                           shape=cube_w.shape,
                           file=filename_format)
     self.assertCubesAreEqual(cube_w, cube_r)
コード例 #2
0
ファイル: rubik_test_interface.py プロジェクト: Borsos/rubik
    def impl_expression_filename(self, shape, dtype, mode):
        shape = Shape(shape)
        dtype = cb.get_dtype(dtype)
        file_format = 'raw'

        out_filename_format = "outcube_{mode}_{{shape}}_{{dtype}}.{{format}}".format(mode=mode)
        out_filename = out_filename_format.format(shape=shape, dtype=dtype.__name__, format=file_format)
        expr_filename = "expr_{mode}.txt".format(mode=mode)
        with open(expr_filename, "w") as f_out:
            f_out.write("""\
cube = cb.linear_cube(shape="{s}", dtype="{d}")
cb.write_cube(file_format="{f}", cube=cube, file="{o}")
""".format(s=shape, d=dtype.__name__, o=out_filename_format, f=file_format))
        if mode == "f_option":
            command = "-f {e}".format(e=expr_filename)
        else:
            command = "-e '@{e}'".format(e=expr_filename)
        returncode, output, error = self.run_program(command)
        self.assertEqual(returncode, 0)
        self.assertFileExistsAndHasShape(out_filename, shape=shape, dtype=dtype)
コード例 #3
0
 def impl_write_read_cube_file_format(self, file_format, cube, filename_format):
     cube_w = cube
     cb.write_cube(file_format=file_format, cube=cube_w, file=filename_format)
     cube_r = cb.read_cube(file_format=file_format, shape=cube_w.shape, file=filename_format)
     self.assertCubesAreEqual(cube_w, cube_r)