Karana.KUtils.Ktyping#
Module containing utilities for modeling and simulation.
- These utilities include:
DataStruct - Used to validate data and catch errors early.
Kclick - Used to easily generate high-quailty CLI applications.
Kquantities - Used to check and convert quantities to the units system used by the simulation.
Submodules#
Attributes#
Functions#
|
Determine if the given value is one of the known quantities. |
|
Ensure that the numpy array is the given shape. |
|
Ensure that if the value is a quantity, that it is the specific provided quantity. |
|
Ensure the given value is within prec of norm. |
Package Contents#
- Karana.KUtils.Ktyping.isQuantity(v: quantities.Quantity | numpy.typing.NDArray, quantity: quantities.Quantity)[source]#
Determine if the given value is one of the known quantities.
- Karana.KUtils.Ktyping.mass: quantities.Quantity#
- Karana.KUtils.Ktyping.inertia: quantities.Quantity#
- Karana.KUtils.Ktyping.length: quantities.Quantity#
- Karana.KUtils.Ktyping.velocity: quantities.Quantity#
- Karana.KUtils.Ktyping.acceleration: quantities.Quantity#
- Karana.KUtils.Ktyping.force: quantities.Quantity#
- Karana.KUtils.Ktyping.torque: quantities.Quantity#
- Karana.KUtils.Ktyping.angular_velocity: quantities.Quantity#
- Karana.KUtils.Ktyping.gravitational_parameter: quantities.Quantity#
- Karana.KUtils.Ktyping.MATH_EPSILON: float = 1e-12#
- Karana.KUtils.Ktyping.npSizeCheck(shape: tuple[int, Ellipsis]) pydantic.AfterValidator[source]#
Ensure that the numpy array is the given shape.
- Parameters:
shape (tuple[int, ...]) – Desired shape of the array. A value of -1 indicates that, that particular axis can be any size. For example, a shape of (3, -1, 2) indicates the first axis must be size 3, the second axis can be any size, and the third axis must be size 2.
- Karana.KUtils.Ktyping.optionallyWithUnits(quantity: quantities.Quantity) pydantic.AfterValidator[source]#
Ensure that if the value is a quantity, that it is the specific provided quantity.
If it has no units, then apply the default units for that quantity to it.
- Parameters:
quantity (pq.Quantity) – The quantity we want the value to be if it is a Quantity. If it is not a Quantity, then apply the defaults units for this Quantity to the value.
- Karana.KUtils.Ktyping.normCheck(norm: float, prec: float = MATH_EPSILON) pydantic.AfterValidator[source]#
Ensure the given value is within prec of norm.
- Parameters:
norm (float) – The value we want the norm to be.
prec (float) – The tolerance for the value to be within that norm.
- Karana.KUtils.Ktyping.Vec#
- Karana.KUtils.Ktyping.Mat#
- Karana.KUtils.Ktyping.Vec3#
- Karana.KUtils.Ktyping.Mat33#
- Karana.KUtils.Ktyping.Mat66#
- Karana.KUtils.Ktyping.Mat6n#
- Karana.KUtils.Ktyping.FloatOrQuantity#
- Karana.KUtils.Ktyping.Mass#
- Karana.KUtils.Ktyping.Length3#
- Karana.KUtils.Ktyping.Velocity3#
- Karana.KUtils.Ktyping.AngularVelocity3#
- Karana.KUtils.Ktyping.Inertia#
- Karana.KUtils.Ktyping.Acceleration3#
- Karana.KUtils.Ktyping.Force3#
- Karana.KUtils.Ktyping.Torque3#
- Karana.KUtils.Ktyping.GravitationalParameter#