Repository: matplotlib/matplotlib
File: lib/matplotlib/spines.py (Python)

Code before:

    def _clear(self):
        """
        Clear things directly related to the spine.

        In this way it is possible to avoid clearing the Axis as well when calling
        from library code where it is known that the Axis is cleared separately.
        """
        self._position = None  # clear position

    def _get_bounds_or_viewLim(self):
        """
        Get the bounds of the spine.

        If self._bounds is None, return self.axes.viewLim.intervalx
        or self.axes.viewLim.intervaly based on self.spine_type
        """
        if self._bounds is not None:
            low, high = self._bounds
        elif self.spine_type in ('left', 'right'):
            low, high = self.axes.viewLim.intervaly
        elif self.spine_type in ('top', 'bottom'):
            low, high = self.axes.viewLim.intervalx
        else:
            raise ValueError(f'spine_type: {self.spine_type} not supported')
            # circle not supported
        return low, high

    def _adjust_location(self):
        """Automatically set spine bounds to the view interval."""

        if self.spine_type == 'circle':
            return

        low, high = self._get_bounds_or_viewLim()

        if self._patch_type == 'arc':
            if self.spine_type in ('bottom', 'top'):
                try:
                    direction = self.axes.get_theta_direction()
                except AttributeError:
                    direction = 1
                try:
                    offset = self.axes.get_theta_offset()
                except AttributeError:
                    offset = 0
                low = low * direction + offset
                high = high * direction + offset
                if low > high:
                    low, high = high, low


Review comment (suggestion):
```suggestion

```
I think this error is not really applicable to the circle spine type, because the two methods that call this one already explicitly handled circle.  More likely this will raise for user- or third party-defined spines.

Code after:

    def _clear(self):
        """
        Clear things directly related to the spine.

        In this way it is possible to avoid clearing the Axis as well when calling
        from library code where it is known that the Axis is cleared separately.
        """
        self._position = None  # clear position

    def _get_bounds_or_viewLim(self):
        """
        Get the bounds of the spine.

        If self._bounds is None, return self.axes.viewLim.intervalx
        or self.axes.viewLim.intervaly based on self.spine_type
        """
        if self._bounds is not None:
            low, high = self._bounds
        elif self.spine_type in ('left', 'right'):
            low, high = self.axes.viewLim.intervaly
        elif self.spine_type in ('top', 'bottom'):
            low, high = self.axes.viewLim.intervalx
        else:
            raise ValueError(f'spine_type: {self.spine_type} not supported')
        return low, high

    def _adjust_location(self):
        """Automatically set spine bounds to the view interval."""

        if self.spine_type == 'circle':
            return

        low, high = self._get_bounds_or_viewLim()

        if self._patch_type == 'arc':
            if self.spine_type in ('bottom', 'top'):
                try:
                    direction = self.axes.get_theta_direction()
                except AttributeError:
                    direction = 1
                try:
                    offset = self.axes.get_theta_offset()
                except AttributeError:
                    offset = 0
                low = low * direction + offset
                high = high * direction + offset
                if low > high:
                    low, high = high, low

                self._path = mpath.Path.arc(np.rad2deg(low), np.rad2deg(high))