Can i set float128 as the standard float-array in numpy Can i set float128 as the standard float-array in numpy numpy numpy

Can i set float128 as the standard float-array in numpy


I don't think there is a central "configuration" you could change to achieve this. Some options what you could do:

  1. If you are creating arrays only by very few of NumPy's factory functions, substitute these functions by your own versions. If you import these functions like

    from numpy import empty

    you can just do

    from numpy import float128, empty as _emptydef empty(*args, **kwargs):    kwargs.update(dtype=float128)    _empty(*args, **kwargs)

    If you are doing

    import numpy

    you can write a module mynumpy.py

    from numpy import *_empty = emptydef empty(*args, **kwargs):    kwargs.update(dtype=float128)    _empty(*args, **kwargs)

    and import it like

    import mynumpy as numpy
  2. Refactor your code to always use dtype=myfloat. This will make such changes easy in the future. You can combine this approach with the use of numpy.empty_like(), numpy.zeros_like() and numpy.ones_like() wherever appropriate to have the actual data type hardcoded in as few places as possible.

  3. Sub-class numpy.ndarray and only use your custom constructors to create new arrays.