# Licensed under a MIT licence - see file `license`
'''Functions to select bases used in a PSF fit.

These functions are meant to be included into a `PSFFitter` object and thus
they all take the ``self`` argument.

All functions here take two arguments:

- ``self``
- ``region``: See `region` for a description

and return a an index array that can be used to select the bases from the base
list.

'''
import numpy as np

__all__ = ['allbases', 'nonmaskedbases']


def allbases(self, region):
    '''Return all available bases.'''
    return np.ones((self.psfbase.shape[2]), dtype=bool)


def nonmaskedbases(self, region):
    '''Return all bases that are not masked in any pixel in region'''
    indbase = ~np.ma.getmaskarray(self.psfbase1d)[region, :]
    # region could have several pixels in it.
    # region could be
    # - np.array/list/tuple of True / False
    # - np.array/list/tuple of index numbers
    check = np.asanyarray(region)
    if (check.dtype == bool and check.sum() == 0) or (len(check) == 0):
        raise ValueError('The input region selects no pixel.')
    else:
        return np.min(indbase, axis=0)

ee804e5bffa8c292bc6982f9cd9da0e3f0b1f53e
<mask token>


def allbases(self, region):
    """Return all available bases."""
    return np.ones(self.psfbase.shape[2], dtype=bool)


<mask token>

<mask token>


def allbases(self, region):
    """Return all available bases."""
    return np.ones(self.psfbase.shape[2], dtype=bool)


def nonmaskedbases(self, region):
    """Return all bases that are not masked in any pixel in region"""
    indbase = ~np.ma.getmaskarray(self.psfbase1d)[region, :]
    check = np.asanyarray(region)
    if check.dtype == bool and check.sum() == 0 or len(check) == 0:
        raise ValueError('The input region selects no pixel.')
    else:
        return np.min(indbase, axis=0)

<mask token>
__all__ = ['allbases', 'nonmaskedbases']


def allbases(self, region):
    """Return all available bases."""
    return np.ones(self.psfbase.shape[2], dtype=bool)


def nonmaskedbases(self, region):
    """Return all bases that are not masked in any pixel in region"""
    indbase = ~np.ma.getmaskarray(self.psfbase1d)[region, :]
    check = np.asanyarray(region)
    if check.dtype == bool and check.sum() == 0 or len(check) == 0:
        raise ValueError('The input region selects no pixel.')
    else:
        return np.min(indbase, axis=0)

<mask token>
import numpy as np
__all__ = ['allbases', 'nonmaskedbases']


def allbases(self, region):
    """Return all available bases."""
    return np.ones(self.psfbase.shape[2], dtype=bool)


def nonmaskedbases(self, region):
    """Return all bases that are not masked in any pixel in region"""
    indbase = ~np.ma.getmaskarray(self.psfbase1d)[region, :]
    check = np.asanyarray(region)
    if check.dtype == bool and check.sum() == 0 or len(check) == 0:
        raise ValueError('The input region selects no pixel.')
    else:
        return np.min(indbase, axis=0)

# Licensed under a MIT licence - see file `license`
'''Functions to select bases used in a PSF fit.

These functions are meant to be included into a `PSFFitter` object and thus
they all take the ``self`` argument.

All functions here take two arguments:

- ``self``
- ``region``: See `region` for a description

and return a an index array that can be used to select the bases from the base
list.

'''
import numpy as np

__all__ = ['allbases', 'nonmaskedbases']


def allbases(self, region):
    '''Return all available bases.'''
    return np.ones((self.psfbase.shape[2]), dtype=bool)


def nonmaskedbases(self, region):
    '''Return all bases that are not masked in any pixel in region'''
    indbase = ~np.ma.getmaskarray(self.psfbase1d)[region, :]
    # region could have several pixels in it.
    # region could be
    # - np.array/list/tuple of True / False
    # - np.array/list/tuple of index numbers
    check = np.asanyarray(region)
    if (check.dtype == bool and check.sum() == 0) or (len(check) == 0):
        raise ValueError('The input region selects no pixel.')
    else:
        return np.min(indbase, axis=0)
