Ejemplo n.º 1
0
    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())
Ejemplo n.º 2
0
    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"])
Ejemplo n.º 3
0
 def loc(self, loc):
     check_is_in(loc, ['inside', 'outside'], label='argument `loc`')
     self._loc = loc
Ejemplo n.º 4
0
def check_valid_correction_name(name):
    check_is_in(name,
                IMPLEMENTED_METHODS + [None],
                label='argument `comparisons_correction`')