Repository: numpy/numpy
File: numpy/_core/getlimits.py (Python)

Code before:
        nexp = get_str("nexp", 6)
        max_ = get_str("max")
        if hasattr(self, "min") and hasattr(self, "max") and -self.min == self.max:
            min_ = "-max"
        else:
            min_ = get_str("min")

        fmt = (
            f'Machine parameters for {self.dtype}\n'
            f'---------------------------------------------------------------\n'
            f'precision = {precision}   resolution = {resolution}\n'
            f'machep = {machep}   eps =        {eps}\n'
            f'negep =  {negep}   epsneg =     {epsneg}\n'
            f'minexp = {minexp}   tiny =       {tiny}\n'
            f'maxexp = {maxexp}   max =        {max_}\n'
            f'nexp =   {nexp}   min =        {min_}\n'
            f'smallest_normal = {smallest_normal}   '
            f'smallest_subnormal = {smallest_subnormal}\n'
            f'---------------------------------------------------------------\n'
        )
        self._fmt = fmt
        return fmt

    def __repr__(self):
        if hasattr(self, "_repr") and self._repr is not None:
            return self._repr

        c = self.__class__.__name__

        # Use precision+1 digits in exponential notation
        fmt_str = _MACHAR_PARAMS.get(self.dtype.type, {}).get('fmt', '%s')
        if fmt_str != '%s' and hasattr(self, 'max') and hasattr(self, 'min'):
            max_str = (fmt_str % self.max).strip()
            min_str = (fmt_str % self.min).strip()
        else:
            max_str = str(self.max)
            min_str = str(self.min)

        resolution_str = str(self.resolution)

        repr_str = (f"{c}(resolution={resolution_str}, min={min_str},"
                    f" max={max_str}, dtype={self.dtype})")
        self._repr = repr_str
        return repr_str

    @cached_property
    def tiny(self):
        """Return the value for tiny, alias of smallest_normal.

        Returns
        -------

Review comment (suggestion):
```suggestion
        if (repr_str := getattr(self, "_repr", None)) is not None:
            return repr_str
```

Code after:
        nexp = get_str("nexp", 6)
        max_ = get_str("max")
        if hasattr(self, "min") and hasattr(self, "max") and -self.min == self.max:
            min_ = "-max"
        else:
            min_ = get_str("min")

        fmt = (
            f'Machine parameters for {self.dtype}\n'
            f'---------------------------------------------------------------\n'
            f'precision = {precision}   resolution = {resolution}\n'
            f'machep = {machep}   eps =        {eps}\n'
            f'negep =  {negep}   epsneg =     {epsneg}\n'
            f'minexp = {minexp}   tiny =       {tiny}\n'
            f'maxexp = {maxexp}   max =        {max_}\n'
            f'nexp =   {nexp}   min =        {min_}\n'
            f'smallest_normal = {smallest_normal}   '
            f'smallest_subnormal = {smallest_subnormal}\n'
            f'---------------------------------------------------------------\n'
        )
        self._fmt = fmt
        return fmt

    def __repr__(self):
        if (repr_str := getattr(self, "_repr", None)) is not None:
            return repr_str

        c = self.__class__.__name__

        # Use precision+1 digits in exponential notation
        fmt_str = _MACHAR_PARAMS.get(self.dtype.type, {}).get('fmt', '%s')
        if fmt_str != '%s' and hasattr(self, 'max') and hasattr(self, 'min'):
            max_str = (fmt_str % self.max).strip()
            min_str = (fmt_str % self.min).strip()
        else:
            max_str = str(self.max)
            min_str = str(self.min)

        resolution_str = str(self.resolution)

        repr_str = (f"{c}(resolution={resolution_str}, min={min_str},"
                    f" max={max_str}, dtype={self.dtype})")
        self._repr = repr_str
        return repr_str

    @cached_property
    def tiny(self):
        """Return the value for tiny, alias of smallest_normal.

        Returns
        -------