예제 #1
0
def test_value():
    """Test getting the value of the data at the current coordinates."""
    np.random.seed(0)
    data = np.random.random((10, 2, 2))
    data[:, 0, :] = 20 * data[:, 0, :]
    layer = Vectors(data)
    value = layer.get_value((0, ) * 2)
    assert value is None
예제 #2
0
class Vectors2DSuite:
    """Benchmarks for the Vectors layer with 2D data"""

    params = [2**i for i in range(4, 18, 2)]

    def setup(self, n):
        np.random.seed(0)
        self.data = np.random.random((n, 2, 2))
        self.layer = Vectors(self.data)

    def time_create_layer(self, n):
        """Time to create an image layer."""
        Vectors(self.data)

    def time_refresh(self, n):
        """Time to refresh view."""
        self.layer.refresh()

    def time_set_view_slice(self, n):
        """Time to set view slice."""
        self.layer._set_view_slice()

    def time_update_thumbnail(self, n):
        """Time to update thumbnail."""
        self.layer._update_thumbnail()

    def time_get_value(self, n):
        """Time to get current value."""
        self.layer.get_value((0, ) * 2)

    def time_width(self, n):
        """Time to update width."""
        self.layer.width = 2

    def time_length(self, n):
        """Time to update length."""
        self.layer.length = 2

    def mem_layer(self, n):
        """Memory used by layer."""
        return self.layer

    def mem_data(self, n):
        """Memory used by raw data."""
        return self.data
예제 #3
0
def test_value_3d(position, view_direction, dims_displayed, world):
    """Currently get_value should return None in 3D"""
    np.random.seed(0)
    data = np.random.random((10, 2, 3))
    data[:, 0, :] = 20 * data[:, 0, :]
    layer = Vectors(data)
    layer._slice_dims([0, 0, 0], ndisplay=3)
    value = layer.get_value(
        position,
        view_direction=view_direction,
        dims_displayed=dims_displayed,
        world=world,
    )
    assert value is None