From 5b14dbbfb4481111d238c67bc62a9b8620b17bf7 Mon Sep 17 00:00:00 2001 From: Tony Tung Date: Tue, 10 Dec 2019 09:09:30 -0800 Subject: [PATCH] [easy] utility function to test equality of two sets of tick markers. This works for both pixel and physical ticks. --- starfish/core/morphology/util.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/starfish/core/morphology/util.py b/starfish/core/morphology/util.py index 72ba2541d..91b346356 100644 --- a/starfish/core/morphology/util.py +++ b/starfish/core/morphology/util.py @@ -1,5 +1,7 @@ from typing import List, Mapping, MutableMapping, Optional, Tuple, Union +import numpy as np + from starfish.core.types import ArrayLike, Axes, Coordinates, Number @@ -58,3 +60,19 @@ def _normalize_physical_ticks( Coordinates(coord): coord_data for coord, coord_data in physical_ticks.items() } + + +def _ticks_equal( + left: Mapping, + right: Mapping, +) -> bool: + """Given two sets of tick marks, return True if the two contain the same keys, and contain the + same data for each key. This works for both pixel ticks and physical ticks. + """ + if left.keys() != right.keys(): + return False + for key in left.keys(): + if not np.all(left[key] == right[key]): + return False + + return True