Beispiel #1
0
def setup():
    """General variables needed by multiple benchmark classes."""
    global data_1d
    global data_2d
    global general_cube

    data_2d = np.zeros((ARTIFICIAL_DIM_SIZE, ) * 2)
    data_1d = data_2d[0]
    general_cube = cube.Cube(data_2d)
Beispiel #2
0
    def setup(self, n_faces):
        mesh_kwargs = dict(
            n_nodes=n_faces + 2, n_edges=n_faces * 2, n_faces=n_faces
        )

        self.mesh_coord = sample_meshcoord(sample_mesh_kwargs=mesh_kwargs)
        self.data = np.zeros(n_faces)
        self.cube_blank = cube.Cube(data=self.data)
        self.cube = self.create()
Beispiel #3
0
    def setup(self):
        # Manufacture data from which contours can be derived.
        # Should generate 10 distinct contours, regardless of dim size.
        dim_size = int(ARTIFICIAL_DIM_SIZE / 5)
        repeat_number = int(dim_size / 10)
        repeat_range = range(int((dim_size ** 2) / repeat_number))
        data = np.repeat(repeat_range, repeat_number)
        data = data.reshape((dim_size,) * 2)

        # These benchmarks are from a user perspective, so setting up a
        # user-level case that will prompt the calling of aux_coords.sort in plot.py.
        dim_coord = coords.DimCoord(np.arange(dim_size))
        local_cube = cube.Cube(data)
        local_cube.add_aux_coord(dim_coord, 0)
        self.cube = local_cube
Beispiel #4
0
 def time_basic(self):
     cube.Cube(data_2d)
Beispiel #5
0
 def create(self):
     """Generic cube creation. cube_kwargs allow dynamic inclusion of
     different components; specified in subclasses."""
     return cube.Cube(data=data_2d, **self.cube_kwargs)
Beispiel #6
0
 def create(self):
     return cube.Cube(
         data=self.data, aux_coords_and_dims=[(self.mesh_coord, 0)]
     )