def __new__(cls, value, times, unit=None, mask=None, dtype=None, copy=True, order=None, ndmin=0): ret = Quantity.__new__(cls, value, unit=unit, dtype=dtype, copy=copy, order=order, subok=True, ndmin=ndmin) if mask is None: mask = np.ones(ret.size, dtype='bool') ret.mask = mask ret.times = times return ret
def __new__(cls, value, unit=None): if (isinstance(value, QueryableAttribute) or isinstance(value, ClauseElement)): unit = Unit(unit) if unit is not None else dimensionless_unscaled value = np.array(value) value = value.view(cls) value._unit = unit return value else: return Quantity.__new__(Quantity, value, unit=unit)
def __new__(cls, value, unit=None): if (isinstance(value, QueryableAttribute) or isinstance(value, ClauseElement)): unit = Unit(unit) if unit is not None else dimensionless_unscaled value = np.array(value) value = value.view(cls) value._unit = unit return value else: return Quantity.__new__(Quantity, value, unit=unit)
def __new__(cls, quantity, name=None, error=None, method=None, diagnostics=None, diagnostics_plot_method=None): # Note: Quantity is peculiar to sub-class because it inherits from numpy ndarray; # see https://docs.astropy.org/en/stable/units/quantity.html#subclassing-quantity. self = Quantity.__new__(cls, quantity.value) self.__dict__ = quantity.__dict__ self.name = name self.error = error self.method = method self.diagnostics = diagnostics self.diagnostics_plot_method = diagnostics_plot_method return self
def __new__(cls, value, unit): """ The constructor ... :param value: :param unit: """ from .unit import PhotometricUnit # Create unit if types.is_string_type(unit): unit = PhotometricUnit(unit) # Call constructor of the base class quantity = Quantity.__new__(cls, value, unit) # Set photometric unit, the base class (Quantity) converts the unit back to an ordinary Unit in the __new__ function above quantity._unit = unit # Return the new quantity return quantity
def __new__(cls, value, unit=None): return Quantity.__new__(cls, value, unit)
def __new__(cls, value, unit=None): return Quantity.__new__(cls, value, unit)