Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    def __new__(cls, value, unit=None):

        return Quantity.__new__(cls, value, unit)
Ejemplo n.º 7
0
    def __new__(cls, value, unit=None):

        return Quantity.__new__(cls, value, unit)