GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — fastplotlib/tests/test_sizes_buffer_manager.py at streamplot · fastplotlib/fastplotlib Expand file tree/ Copy pathtest_sizes_buffer_manager.pyMore file actions 70 lines (54 loc) · 2.11 KB / Copy pathtest_sizes_buffer_manager.pyFile metadata and controls70 lines (54 loc) · 2.11 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 import numpy as np from numpy import testing as npt import pytest from fastplotlib.graphics.features import VertexPointSizes from .utils import generate_slice_indices def generate_data(input_type: str) -> np.ndarray | float: """ Point sizes varying with a sine wave Parameters ---------- input_type: str one of "sine", "cosine", or "float" """ if input_type == "float": return 10.0 xs = np.linspace(0, 10 * np.pi, 10) if input_type == "sine": return np.abs(np.sin(xs)).astype(np.float32) if input_type == "cosine": return np.abs(np.cos(xs)).astype(np.float32) @pytest.mark.parametrize("data", [generate_data(v) for v in ["float", "sine"]]) def test_create_buffer(data): sizes = VertexPointSizes(data, n_datapoints=10) if isinstance(data, float): npt.assert_almost_equal(sizes[:], generate_data("float")) elif isinstance(data, np.ndarray): npt.assert_almost_equal(sizes[:], generate_data("sine")) @pytest.mark.parametrize( "slice_method", [generate_slice_indices(i) for i in range(0, 16)] ) @pytest.mark.parametrize("user_input", ["float", "cosine"]) def test_slice(slice_method: dict, user_input: str): data = generate_data("sine") s = slice_method["slice"] indices = slice_method["indices"] offset = slice_method["offset"] size = slice_method["size"] others = slice_method["others"] sizes = VertexPointSizes(data, n_datapoints=10) match user_input: case "float": sizes[s] = 20.0 truth = np.full(len(indices), 20.0) npt.assert_almost_equal(sizes[s], truth) npt.assert_almost_equal(sizes[indices], truth) # make sure other sizes not modified npt.assert_almost_equal(sizes[others], data[others]) case "cosine": cosine = generate_data("cosine") sizes[s] = cosine[s] npt.assert_almost_equal(sizes[s], cosine[s]) npt.assert_almost_equal(sizes[indices], cosine[s]) # make sure other sizes not modified npt.assert_almost_equal(sizes[others], data[others]) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |