From b111d3789a202fbee92ec8db7aae6ceb6dfee247 Mon Sep 17 00:00:00 2001 From: Scott Shambaugh <14363975+scottshambaugh@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:40:40 -0700 Subject: [PATCH] fix tests --- docs/gen_graphics.py | 2 +- src/mpl_stereo/AxesStereo.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/gen_graphics.py b/docs/gen_graphics.py index ae93f70..bffb933 100644 --- a/docs/gen_graphics.py +++ b/docs/gen_graphics.py @@ -49,7 +49,7 @@ def animate_2d_trefoil(savedir): def animate(frame): x, y, z = generate_trefoil(frame) - x, y, z = sort_by_z(x, y, z) + x, y, z, _ = sort_by_z(x, y, z, kwargs=dict()) offset_left, offset_right = calc_2d_offsets(axstereo.focal_plane, z, axstereo.z_scale, axstereo.d, axstereo.ipd) scatter[0].set_offsets(np.stack([x + offset_left, y]).T) diff --git a/src/mpl_stereo/AxesStereo.py b/src/mpl_stereo/AxesStereo.py index e3fbb4d..bce1b2a 100644 --- a/src/mpl_stereo/AxesStereo.py +++ b/src/mpl_stereo/AxesStereo.py @@ -9,7 +9,7 @@ from matplotlib.figure import Figure ## Functions -def sort_by_z(x: np.ndarray, y: np.ndarray, z: np.ndarray, kwargs: dict[str, Any] = None): +def sort_by_z(x: np.ndarray, y: np.ndarray, z: np.ndarray, kwargs: dict[str, Any]): """ Sorts the provided data arrays based on the z values, to avoid improper occlusion in visualizations. @@ -32,13 +32,11 @@ def sort_by_z(x: np.ndarray, y: np.ndarray, z: np.ndarray, kwargs: dict[str, Any x = x[sort_idx] y = y[sort_idx] z = z[sort_idx] - if kwargs is None: - return x, y, z - elif 'c' in kwargs and np.array(kwargs['c']).shape == np.array(z).shape: + if 'c' in kwargs and np.array(kwargs['c']).shape == np.array(z).shape: c = kwargs.pop('c') c = c[sort_idx] kwargs['c'] = c - return x, y, z, kwargs + return x, y, z, kwargs def process_args(ax_method: Any, known_methods: list[str], args: Any, kwargs: dict[str, Any]):