MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / V

Function V

src/ifcopenshell-python/ifcopenshell/util/shape_builder.py:54–65  ·  view source on GitHub ↗

Convert floats / vector / sequence of vectors to numpy array. Note that `float` argument type also allows passing ints, which will be converted to floats (a double type) as IfcOpenShell is strict about setting int/float attributes.

(*args: Union[float, int, VectorType, SequenceOfVectors])

Source from the content-addressed store, hash-verified

52
53
54def V(*args: Union[float, int, VectorType, SequenceOfVectors]) -> npt.NDArray[np.float64]:
55 """Convert floats / vector / sequence of vectors to numpy array.
56
57 Note that `float` argument type also allows passing ints,
58 which will be converted to floats (a double type) as IfcOpenShell is strict
59 about setting int/float attributes.
60 """
61 if isinstance(args[0], (float, int)):
62 return np.array(args, dtype="d")
63
64 assert len(args) == 1, "Only single argument is supported if providing a vector or a sequence of them."
65 return np.array(args[0], dtype="d")
66
67
68def ifc_safe_vector_type(v: Union[VectorType, SequenceOfVectors]) -> Any:

Calls

no outgoing calls