<NME> util.py
<BEF> """Function helpers.
"""Function helpers.

"""

import numpy as np

from astropy.coordinates import angles
from astropy import units as u

from poliastro.jit import jit


def rotate(vector, angle, axis='z', unit=None):
    """Rotates a vector around axis a right-handed positive angle.
def norm(vec, axis=None):
    """Norm of a Quantity vector that respects units.

    Parameters
    ----------
    vec : ~astropy.units.Quantity
        Vector with units.
    axis : int or None
        Axis along which to compute the vector norms.

    """
    if axis is not None:
        # axis keyword argument is not yet supported by numba,
        # see https://github.com/numba/numba/issues/2558
        from numpy.linalg import norm as norm_np

        result = norm_np(vec.value, axis=axis)
    else:
        result = norm_fast(vec.value)

    return result << vec.unit


def time_range(
    start, *, num_values=50, spacing=None, end=None, format=None, scale=None
):
    """Generates range of astronomical times.

    .. versionadded:: 0.8.0

    Parameters
    ----------
    start : ~astropy.time.Time or ~astropy.units.Quantity
        Start time.
    num_values : int, optional
        Number of equal spaced time values to be generated, default to 50.
    spacing : ~astropy.time.Time or ~astropy.units.Quantity, optional
        Spacing between periods, optional.
    end : ~astropy.time.Time or equivalent, optional
        End date.

    Returns
    -------
    result: ~astropy.time.Time
        Array of time values.

    """
    start = Time(start, format=format, scale=scale)

    if spacing is not None and end is None:
        result = start + spacing * np.arange(0, num_values)

    elif end is not None and spacing is None:
        end = Time(end, format=format, scale=scale)
        result = start + (end - start) * np.linspace(0, 1, num_values)

    else:
        raise ValueError("Either 'end' or 'spacing' must be specified")

    return result


    """
    return np.sqrt(vec.dot(vec))


@jit('f8(f8[:], f8[:])')
def dot(u, v):
    """Returns the dot product of two vectors.

    """
    dp = 0.0
    for ii in range(u.shape[0]):
        dp += u[ii] * v[ii]
    return dp
    """Calculates the closest value in the given values.

    Parameters
    ----------
    value : ~astropy.units.Quantity
        Reference value.
    values : ~astropy.units.Quantity
        Values to search from.

    """
    index = np.abs(np.asarray(values) * u.rad - value).argmin()
    return values[index]


@u.quantity_input(start=u.rad, stop=u.rad)
def alinspace(start, stop=None, *, num=50, endpoint=True):
    """Return increasing, evenly spaced angular values over a specified interval."""
    if stop is None:
        stop = start + 2 * np.pi * u.rad

    return (
        alinspace_fast(
            start.to_value(u.rad), stop.to_value(u.rad), num, endpoint
        )
        * u.rad
    )


@u.quantity_input(angle=u.rad, limit=u.rad)
def wrap_angle(angle, limit=180 * u.deg):
    return Angle(angle).wrap_at(limit)

<MSG> Merge pull request #100 from Juanlu001/drop-dot#89

Drop `util.dot` in favor of `np.dot`
<DFF> @@ -2,14 +2,11 @@
 """Function helpers.
 
 """
-
 import numpy as np
 
 from astropy.coordinates import angles
 from astropy import units as u
 
-from poliastro.jit import jit
-
 
 def rotate(vector, angle, axis='z', unit=None):
     """Rotates a vector around axis a right-handed positive angle.
@@ -77,14 +74,3 @@ def norm(vec):
 
     """
     return np.sqrt(vec.dot(vec))
-
-
-@jit('f8(f8[:], f8[:])')
-def dot(u, v):
-    """Returns the dot product of two vectors.
-
-    """
-    dp = 0.0
-    for ii in range(u.shape[0]):
-        dp += u[ii] * v[ii]
-    return dp

{'addition_count': 0, 'commit_subject': 'Merge pull request #100 from Juanlu001/drop-dot#89', 'deletion_count': 14, 'file_extension': '.py', 'lang': 'py', 'license': 'mit', 'repo_name': 'poliastro/poliastro'}