arte/utils/gpu.py
def _make_sure_first_arg_is_little_endian(f):
    '''
    Decorator to enforce little endianess with cupy.

    This is a workaround for the cupy issue with FITS files:
    https://github.com/cupy/cupy/issues/3652

    It will analyze the first argument and, if it is
    a big-endian array (like the ones returned by astropy.io.fits.getdata),
    convert it to a little-endian one before passing it to the function.

    Can be used to "patch" the cupy routines as follows::

        cupy.array = _make_sure_first_arg_is_little_endian(cupy.array)
        cupy.asarray = _make_sure_first_arg_is_little_endian(cupy.asarray)
    '''
    @wraps(f)
    def wrapper(data, *args, **kwargs):
        import sys
        import numpy

        if isinstance(data, numpy.ndarray):
            # Use names compatible with sys.byteorder
            endianess_map = {
                '>': 'big',
                '<': 'little',
                '=': sys.byteorder,
                '|': 'not relevant'
            }
            endianess = endianess_map[data.dtype.byteorder]
            if endianess == 'big':
               print('Array %s %s must be converted from big to little endian' %
                     (str(data.dtype), str(data.shape)))
               data = data.astype(data.dtype.newbyteorder('<'))

        return f(data, *args, **kwargs)

    return wrapper

    Decorator to enforce little endianess with cupy.

    This is a workaround for the cupy issue with FITS files:
    https://github.com/cupy/cupy/issues/3652

    It will analyze the first argument and, if it is
    a big-endian array (like the ones returned by astropy.io.fits.getdata),
    convert it to a little-endian one before passing it to the function.

    Can be used to "patch" the cupy routines as follows::

        cupy.array = _make_sure_first_arg_is_little_endian(cupy.array)
        cupy.asarray = _make_sure_first_arg_is_little_endian(cupy.asarray)
    
Decorator to enforce little endianess with cupy.

It will analyze the first argument and, if it is
a big-endian array (like the ones returned by astropy.io.fits.getdata),
convert it to a little-endian one before passing it to the function.

Can be used to "patch" the cupy routines as follows:.


Decorator to enforce little endianess with cupy . It will analyze the first argument and if it is a big - endian array ( like the ones returned by astropy . io . fits . getdata ) convert it to a little - endian one before passing it to the function . Can be used to " patch " the cupy routines as follows : .
def _make_sure_first_arg_is_little_endian(f):
    @wraps(f)
    def wrapper(data, *args, **kwargs):
        import sys
        import numpy
        if isinstance(data, numpy.ndarray):
            endianess_map = {
                '>': 'big',
                '<': 'little',
                '=': sys.byteorder,
                '|': 'not relevant'
            }
            endianess = endianess_map[data.dtype.byteorder]
            if endianess == 'big':
               print('Array %s %s must be converted from big to little endian' %
                     (str(data.dtype), str(data.shape)))
               data = data.astype(data.dtype.newbyteorder('<'))
        return f(data, *args, **kwargs)
    return wrapper
def _make_sure_first_arg_is_little_endian ( f ) : @ wraps ( f ) def wrapper ( data , * args , ** kwargs ) : import sys import numpy if isinstance ( data , numpy . ndarray ) : endianess_map = { '>' : 'big' , '<' : 'little' , '=' : sys . byteorder , '|' : 'not relevant' } endianess = endianess_map [ data . dtype . byteorder ] if endianess == 'big' : print ( 'Array %s %s must be converted from big to little endian' % ( str ( data . dtype ) , str ( data . shape ) ) ) data = data . astype ( data . dtype . newbyteorder ( '<' ) ) return f ( data , * args , ** kwargs ) return wrapper
Decorator to enforce little endianess with cupy.
Decorator to enforce little endianess with cupy .
'''
    Decorator to enforce little endianess with cupy.

    This is a workaround for the cupy issue with FITS files:
    https://github.com/cupy/cupy/issues/3652

    It will analyze the first argument and, if it is
    a big-endian array (like the ones returned by astropy.io.fits.getdata),
    convert it to a little-endian one before passing it to the function.

    Can be used to "patch" the cupy routines as follows::

        cupy.array = _make_sure_first_arg_is_little_endian(cupy.array)
        cupy.asarray = _make_sure_first_arg_is_little_endian(cupy.asarray)
    ''' # Use names compatible with sys.byteorder
f