Return the unit vector.
503815
def unit_vector(self):
        """"""
        return Point2D( self.x / self.magnitude, self.y / self.magnitude )
539901
def ordered(self):
        """"""
        active, inactive = self.active_inactive
        order = active + inactive
        return UnitCell(self.matrix[:,order], self.active[order])
717207
def to_unit(C, val, unit=None):
        """"""
        md = re.match(r'^(?P<num>[\d\.]+)(?P<unit>.*)$', val)
        if md is not None:
            un = float(md.group('num')) * CSS.units[md.group('unit')]
            if unit is not None:
                return un.asUnit(unit)
            else:
                return un
1360873
def H(self) -> 'QubitVector':
        """"""
        N = self.qubit_nb
        R = self.rank

        # (super) operator transpose
        tensor = self.tensor
        tensor = bk.reshape(tensor, [2**(N*R//2)] * 2)
        tensor = bk.transpose(tensor)
        tensor = bk.reshape(tensor, [2] * R * N)

        tensor = bk.conj(tensor)

        return QubitVector(tensor, self.qubits)
1325531
def to_unit(self, unit):
        """"""
        new_data_c = self.duplicate()
        new_data_c.convert_to_unit(unit)
        return new_data_c
460895
def unit_conversion(thing, units, length=False):
    """"""
    if 'n/a' == thing:
        return 'n/a'
    try:
        thing = round(thing * CONVERSION[units][0 + length], 2)
    except TypeError:
        thing = 'fubar'
    return thing, CONVERSION[units][2 + length]
46196
def convert_to_unit(self, unit):
        """"""
        self._values = self._header.data_type.to_unit(
            self._values, unit, self._header.unit)
        self._header._unit = unit
855483
def fromvector(cls, v):
        """"""
        w = v.normalized()
        return cls(w.x, w.y, w.z)
1051365
def getUs(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
    """"""
    w, v = admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau)
    b0s = 11 - 2 * f / 3
    a = w / (2 * b0s)
    return v @ np.diag(eta_s**a) @ np.linalg.inv(v)
159838
def _call(self, x, out=None):
        """"""
        if out is None:
            return self.operator(x) * self.vector
        else:
            self.operator(x, out=out)
            out *= self.vector
888887
def VectorLen(self, off):
        """"""
        N.enforce_number(off, N.UOffsetTFlags)

        off += self.Pos
        off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
        ret = encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
        return ret
1115122
def obj_with_unit(obj, unit):
    
    unit_type = _UNAME2UTYPE[unit]

    if isinstance(obj, numbers.Number):
        return FloatWithUnit(obj, unit=unit, unit_type=unit_type)
    elif isinstance(obj, collections.Mapping):
        return {k: obj_with_unit(v, unit) for k,v in obj.items()}
    else:
        return ArrayWithUnit(obj, unit=unit, unit_type=unit_type)
334254
def units(self):
        
        self._units, value = self.get_attr_string(self._units, 'units')
        return value
664805
def ndim(self):
        """"""
        try:
            return self.__ndim
        except AttributeError:
            ndim = len(self.coord_vectors)
            self.__ndim = ndim
            return ndim
1009087
def vec(self):
        
        return np.r_[self.fx, self.fy, self.cx, self.cy, self.skew, self.height, self.width]
913905
def matrix(self):
        """"""
        result = np.identity(4, float)
        result[0:3, 0:3] = self.r
        return result
532366
def copy(self):
        """"""
        cpy_vec = Vector4()
        cpy_vec.x = self.x
        cpy_vec.y = self.y
        cpy_vec.z = self.z
        cpy_vec.w = self.w
        return cpy_vec