Module astrapy.data.utils.vector_coercion
Functions
def convert_vector_to_floats(vector: Iterable[Any]) ‑> list[float]-
Expand source code
def convert_vector_to_floats(vector: Iterable[Any]) -> list[float]: """ Convert a vector of strings to a vector of floats. Args: vector (list): A vector of objects. Returns: list: A vector of floats. """ return [float(value) for value in vector]Convert a vector of strings to a vector of floats.
Args
vector:list- A vector of objects.
Returns
list- A vector of floats.
def ensure_unrolled_if_iterable(value: Any) ‑> Any-
Expand source code
def ensure_unrolled_if_iterable(value: Any) -> Any: if isinstance(value, Iterable) and not isinstance(value, (ITERABLES_TO_NOT_UNROLL)): return list(value) return value def is_list_of_floats(vector: Iterable[Any]) ‑> bool-
Expand source code
def is_list_of_floats(vector: Iterable[Any]) -> bool: """ Safely determine if it's a list of floats. Assumption: if list, and first item is float, then all items are. """ return isinstance(vector, list) and ( len(vector) == 0 or isinstance(vector[0], float) or isinstance(vector[0], int) )Safely determine if it's a list of floats. Assumption: if list, and first item is float, then all items are.