Create a quantity. This can be from a scalar or vector.

    Example::

      q1 = quantity(1.0, "km/s")
      q2 = quantity("1km/s")
      q1 = quantity([1.0,2.0], "km/s")
977273
def quantity(*args):
    
    if len(args) == 1:
        if isinstance(args[0], str):
            # use copy constructor to create quantity from string
            return Quantity(from_string(args[0]))
        elif isinstance(args[0], dict):
            if hasattr(args[0]["value"], "__len__"):
                return QuantVec(from_dict_v(args[0]))
            else:
                return Quantity(from_dict(args[0]))
        elif isinstance(args[0], Quantity) or isinstance(args[0], QuantVec):
            return args[0]
        else:
            raise TypeError("Invalid argument type for")
    else:
        if hasattr(args[0], "__len__"):
            return QuantVec(*args)
        else:
            return Quantity(*args)
1202790
def _create_s(y, h):
        """"""
        s = np.zeros_like(y)
        s[:-1] = (y[1:] - y[:-1]) / h[:-1]
        s[-1] = 0.0
        return s
1303489
def to_float(unit):
    
    def converter(x):
        """Convert the input to a `float` in %s
        """
        return Quantity(x, unit).value

    converter.__doc__ %= str(unit)  # pylint: disable=no-member
    return converter
622867
def new_inertial(name=None, pos=(0, 0, 0), mass=None, **kwargs):
    
    if mass is not None:
        kwargs["mass"] = str(mass)
    kwargs["pos"] = array_to_string(pos)
    element = ET.Element("inertial", attrib=kwargs)
    return element
981721
def scalar(magnitude = 1)
      terms.reduce(1) do |prod, term|
        prod * term.scalar(magnitude)
      end
    end
1045784
def create(lr, alpha, momentum=0, weight_decay=0, epsilon=1e-8):
    
    return RMSpropTFFactory(lr=lr, alpha=alpha, momentum=momentum, weight_decay=weight_decay, eps=float(epsilon))
821111
function Vector(x, y) {
    this.x = x != null ? x : 0.0;
    this.y = y != null ? y : 0.0;
  }
894854
def _quantityToReal(self, quantity):
        
        if not quantity:
            return 1.0

        try:
            return float(quantity.replace(',', '.'))
        except ValueError:
            pass

        try:
            return float(self.ptc.numbers[quantity])
        except KeyError:
            pass

        return 0.0
313240
def p_speed_constructor(self, p):
        ''
        logger.debug('speed = number %s, speed unit %s', p[1], p[2])
        information_unit, duration = p[2]
        information = Information.from_quantity_unit(p[1], information_unit)
        p[0] = information.in_duration(duration)
635430
def dot(a, b):
    """
    if isinstance(a, Mul):
        a = a.expand()
        avect = 1
        aivect = -1
        for ai, fact in enumerate(a.args):
            if isinstance(fact, Vector3D):
                avect = fact
                aivect = ai
                break

        acoef = a.args[:aivect] + a.args[aivect+1:]
        acoef = Mul(*acoef)
        return acoef*dot(avect, b)

    if isinstance(b, Mul):
        b = b.expand()
        bvect = 1
        bivect = -1
        for bi, fact in enumerate(b.args):
            if isinstance(fact, Vector3D):
                bvect = fact
                bivect = bi
                break

        bcoef = b.args[:bivect] + b.args[bivect+1:]
        bcoef = Mul(*bcoef)
        return bcoef*dot(a, bvect)

    if isinstance(a, Vector3D) and isinstance(b, Vector3D):
        return DotProduct(a, b)

    if hasattr(a, "shape") and hasattr(b, "shape"):
        return cartesian_dot_product(a, b)

    print a, b, type(a), type(b),
    print isinstance(a, Vector3D), isinstance(b, Vector3D)
    raise NotImplementedError("could not catch these instances in dot!")
429762
def *(other)
      case other
      when Mat3    then mul_mat3(other)
      when Vec3    then mul_vec3(other)
      when Numeric then mul_scalar(other)
      else raise ArgumentError, "Don't know how to multiply Mat3 with object: #{other.inspect}"
      end
    end
1015913
def dot(r1, r2):
    
    if r1.size != r2.size:
        raise ValueError("Both arguments must have the same input size.")
    if r1.deriv != r2.deriv:
        raise ValueError("Both arguments must have the same deriv.")
    return r1.x*r2.x + r1.y*r2.y + r1.z*r2.z
30446
def __set_quantity(self, value):
        '''
        
        '''
        try:
            if value < 0:
                raise ValueError()

            self.__quantity = Decimal(str(value))
        except ValueError:
            raise ValueError("Quantity must be a positive number")
91655
def assert_angle(name, q):
    
    if isinstance(q, u.Quantity):
        if q.unit.physical_type == 'angle':
            pass
        else:
            raise ValueError("{0} should have angular units".format(name))
    else:
        raise TypeError("{0} should be a Quantity instance".format(name))
709484
def create_new_example(self, foo='', a='', b=''):
        """"""
        return create_new_example(foo=foo, a=a, b=b)
659829
def vector_dot(vector1, vector2):
    
    try:
        if vector1 is None or len(vector1) == 0 or vector2 is None or len(vector2) == 0:
            raise ValueError("Input vectors cannot be empty")
    except TypeError as e:
        print("An error occurred: {}".format(e.args[-1]))
        raise TypeError("Input must be a list or tuple")
    except Exception:
        raise

    # Compute dot product
    prod = 0.0
    for v1, v2 in zip(vector1, vector2):
        prod += v1 * v2

    # Return the dot product of the input vectors
    return prod
303245
def compute_quantity(self, quantity):
        
        quantity = quantity.copy()
        expression = self.model.replace(quantity.pop('expression'), self.replacements)
        variables = self.all_variables[len(self.free_variables) + 1:]
        function = self.model.lambdify(expression, variables, **self.lambdify_options)
        quantity['value'] = function(*(self.fitted_parameters + self.fixed_values)) * prefix_factor(quantity)**(-1)
        return quantity