def get_transform_func(self, kind: str): """ Given an axis object, returns one of three possible transformation functions to move between coordinate systems, depending on the value of kind: 'data_to_ax': converts data coordinates to axes coordinates 'ax_to_data': converts axes coordinates to data coordinates 'pix_to_ax': converts pixel coordinates to axes coordinates 'all': return tuple of all three This function should be called whenever axes limits are altered. """ check_is_in(kind, ['data_to_ax', 'ax_to_data', 'pix_to_ax', 'all'], 'kind') if kind == 'pix_to_ax': return self.ax.transAxes.inverted() transform = {'v': self.ax.get_xaxis_transform, 'h': self.ax.get_yaxis_transform}[self.orient] data_to_ax = \ self.ax.transData + transform().inverted() if kind == 'data_to_ax': return data_to_ax elif kind == 'ax_to_data': return data_to_ax.inverted() else: return (data_to_ax, data_to_ax.inverted(), self.ax.transAxes.inverted())
def test_check_is_in(self): with self.assertRaisesRegex(ValueError, "'then']; got `this`"): check_is_in("this", ["that", "there", "then"]) check_is_in("this", ["that", "there", "then", "this"])
def loc(self, loc): check_is_in(loc, ['inside', 'outside'], label='argument `loc`') self._loc = loc
def check_valid_correction_name(name): check_is_in(name, IMPLEMENTED_METHODS + [None], label='argument `comparisons_correction`')