unitforge 0.5.4__tar.gz → 0.5.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. {unitforge-0.5.4 → unitforge-0.5.6}/Cargo.lock +2 -2
  2. {unitforge-0.5.4 → unitforge-0.5.6}/Cargo.toml +2 -2
  3. {unitforge-0.5.4 → unitforge-0.5.6}/PKG-INFO +1 -1
  4. {unitforge-0.5.4 → unitforge-0.5.6}/python/unitforge/__init__.pyi +43 -0
  5. {unitforge-0.5.4 → unitforge-0.5.6}/src/impl_macros.rs +12 -0
  6. {unitforge-0.5.4 → unitforge-0.5.6}/src/lib.rs +2 -0
  7. unitforge-0.5.6/src/quantities/strain_squared.rs +36 -0
  8. {unitforge-0.5.4 → unitforge-0.5.6}/src/relations.rs +1 -0
  9. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/relations.rs +13 -0
  10. {unitforge-0.5.4 → unitforge-0.5.6}/unitforge_macros/Cargo.toml +1 -1
  11. {unitforge-0.5.4 → unitforge-0.5.6}/.gitignore +0 -0
  12. {unitforge-0.5.4 → unitforge-0.5.6}/.gitlab-ci.yml +0 -0
  13. {unitforge-0.5.4 → unitforge-0.5.6}/Readme.md +0 -0
  14. {unitforge-0.5.4 → unitforge-0.5.6}/Readme_py.md +0 -0
  15. {unitforge-0.5.4 → unitforge-0.5.6}/install_hooks.sh +0 -0
  16. {unitforge-0.5.4 → unitforge-0.5.6}/pyproject.toml +0 -0
  17. {unitforge-0.5.4 → unitforge-0.5.6}/python/unitforge/__init__.py +0 -0
  18. {unitforge-0.5.4 → unitforge-0.5.6}/python/unitforge/py.typed +0 -0
  19. {unitforge-0.5.4 → unitforge-0.5.6}/scripts/generate_python_stubs.py +0 -0
  20. {unitforge-0.5.4 → unitforge-0.5.6}/src/errors.rs +0 -0
  21. {unitforge-0.5.4 → unitforge-0.5.6}/src/internal.rs +0 -0
  22. {unitforge-0.5.4 → unitforge-0.5.6}/src/prelude.rs +0 -0
  23. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/acceleration.rs +0 -0
  24. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/angle.rs +0 -0
  25. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/angular_acceleration.rs +0 -0
  26. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/angular_velocity.rs +0 -0
  27. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/area.rs +0 -0
  28. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/area_of_moment.rs +0 -0
  29. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/charge.rs +0 -0
  30. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/compliance.rs +0 -0
  31. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/density.rs +0 -0
  32. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/density_rate.rs +0 -0
  33. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/density_temperature.rs +0 -0
  34. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/density_temperature_rate.rs +0 -0
  35. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/distance.rs +0 -0
  36. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force.rs +0 -0
  37. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_area.rs +0 -0
  38. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_distance.rs +0 -0
  39. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_div_distance_power_four.rs +0 -0
  40. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_per_volume.rs +0 -0
  41. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_stress.rs +0 -0
  42. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/force_volume.rs +0 -0
  43. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/frequency.rs +0 -0
  44. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/inverse_angle.rs +0 -0
  45. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/inverse_area.rs +0 -0
  46. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/inverse_distance.rs +0 -0
  47. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/inverse_stress.rs +0 -0
  48. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/mass.rs +0 -0
  49. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/mass_per_distance.rs +0 -0
  50. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/molar_mass.rs +0 -0
  51. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/pressure_rate.rs +0 -0
  52. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/rotational_stiffness.rs +0 -0
  53. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/specific_gas_constant.rs +0 -0
  54. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stiffness.rs +0 -0
  55. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/strain.rs +0 -0
  56. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress.rs +0 -0
  57. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress_cubed.rs +0 -0
  58. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress_per_temperature.rs +0 -0
  59. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress_rate.rs +0 -0
  60. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress_rate_per_temperature.rs +0 -0
  61. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/stress_squared.rs +0 -0
  62. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/temperature.rs +0 -0
  63. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/time.rs +0 -0
  64. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/universal_gas_constant.rs +0 -0
  65. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/velocity.rs +0 -0
  66. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/velocity_squared.rs +0 -0
  67. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/voltage.rs +0 -0
  68. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities/volume.rs +0 -0
  69. {unitforge-0.5.4 → unitforge-0.5.6}/src/quantities.template.rs +0 -0
  70. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/bindings/matrix3_py.template.rs +0 -0
  71. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/bindings/vector3_py.template.rs +0 -0
  72. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/matrix2.rs +0 -0
  73. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/matrix2x3.rs +0 -0
  74. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/matrix3.rs +0 -0
  75. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/matrix3x2.rs +0 -0
  76. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/vector2.rs +0 -0
  77. {unitforge-0.5.4 → unitforge-0.5.6}/src/small_linalg/vector3.rs +0 -0
  78. {unitforge-0.5.4 → unitforge-0.5.6}/test.sh +0 -0
  79. {unitforge-0.5.4 → unitforge-0.5.6}/tests/common/mod.rs +0 -0
  80. {unitforge-0.5.4 → unitforge-0.5.6}/tests/matrix2.rs +0 -0
  81. {unitforge-0.5.4 → unitforge-0.5.6}/tests/matrix2x3.rs +0 -0
  82. {unitforge-0.5.4 → unitforge-0.5.6}/tests/matrix3.rs +0 -0
  83. {unitforge-0.5.4 → unitforge-0.5.6}/tests/matrix3x2.rs +0 -0
  84. {unitforge-0.5.4 → unitforge-0.5.6}/tests/ndarray_dot.rs +0 -0
  85. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantities.rs +0 -0
  86. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/constants.rs +0 -0
  87. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/construction.rs +0 -0
  88. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/enum_iter.rs +0 -0
  89. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/metadata.rs +0 -0
  90. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/normalization.rs +0 -0
  91. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/plain_storage.rs +0 -0
  92. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/runtime_quantity.rs +0 -0
  93. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core/scalar_edges.rs +0 -0
  94. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_core.rs +0 -0
  95. {unitforge-0.5.4 → unitforge-0.5.6}/tests/quantity_serde.rs +0 -0
  96. {unitforge-0.5.4 → unitforge-0.5.6}/tests/small_linalg_edge_cases.rs +0 -0
  97. {unitforge-0.5.4 → unitforge-0.5.6}/tests/small_linalg_interfaces.rs +0 -0
  98. {unitforge-0.5.4 → unitforge-0.5.6}/tests/test_quantities.py +0 -0
  99. {unitforge-0.5.4 → unitforge-0.5.6}/tests/test_small_linalg.py +0 -0
  100. {unitforge-0.5.4 → unitforge-0.5.6}/tests/typecheck/mypy_smoke.py +0 -0
  101. {unitforge-0.5.4 → unitforge-0.5.6}/tests/vector2.rs +0 -0
  102. {unitforge-0.5.4 → unitforge-0.5.6}/tests/vector3.rs +0 -0
  103. {unitforge-0.5.4 → unitforge-0.5.6}/unitforge_macros/src/lib.rs +0 -0
@@ -351,7 +351,7 @@ checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
351
351
 
352
352
  [[package]]
353
353
  name = "unitforge"
354
- version = "0.5.4"
354
+ version = "0.5.6"
355
355
  dependencies = [
356
356
  "ndarray",
357
357
  "num-traits",
@@ -367,7 +367,7 @@ dependencies = [
367
367
 
368
368
  [[package]]
369
369
  name = "unitforge_macros"
370
- version = "0.5.4"
370
+ version = "0.5.6"
371
371
  dependencies = [
372
372
  "regex",
373
373
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "unitforge"
3
- version = "0.5.4"
3
+ version = "0.5.6"
4
4
  edition = "2021"
5
5
  authors = ["Dr.Q team <info@askdrq.com>", "Henrik Stromberg <henrik@askdrq.com>"]
6
6
  description = "A library for unit and quantity consistent computations in Rust"
@@ -20,7 +20,7 @@ pyo3 = { version = "0.28.3", features = ["extension-module", "auto-initialize",
20
20
  numpy = { version = "0.28.0", optional = true }
21
21
  strum = { version = "0.28.0", optional = true }
22
22
  strum_macros = { version = "0.28.0", optional = true }
23
- unitforge_macros = { version = "0.5.4", path = "unitforge_macros" }
23
+ unitforge_macros = { version = "0.5.6", path = "unitforge_macros" }
24
24
 
25
25
  [features]
26
26
  default = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitforge
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -2066,6 +2066,8 @@ class Strain:
2066
2066
  @overload
2067
2067
  def __mul__(self, rhs: "Distance") -> "Distance": ...
2068
2068
  @overload
2069
+ def __mul__(self, rhs: "Strain") -> "StrainSquared": ...
2070
+ @overload
2069
2071
  def __mul__(self, rhs: "Stress") -> "Stress": ...
2070
2072
  @overload
2071
2073
  def __mul__(self, rhs: Any) -> Any: ...
@@ -2085,6 +2087,47 @@ class Strain:
2085
2087
  def __repr__(self) -> str: ...
2086
2088
  def __str__(self) -> str: ...
2087
2089
 
2090
+ class StrainSquaredUnit:
2091
+ msq_msq: ClassVar["StrainSquaredUnit"]
2092
+
2093
+ class StrainSquared:
2094
+ def __init__(self, value: float, unit: "StrainSquaredUnit") -> None: ...
2095
+ @classmethod
2096
+ def zero(cls: Type["StrainSquared"]) -> "StrainSquared": ...
2097
+ def to(self, unit: "StrainSquaredUnit") -> float: ...
2098
+ def close_abs(self, other: "StrainSquared", threshold: "StrainSquared") -> bool: ...
2099
+ def close_rel(self, other: "StrainSquared", threshold: float) -> bool: ...
2100
+ def __neg__(self) -> "StrainSquared": ...
2101
+ def __abs__(self) -> "StrainSquared": ...
2102
+ def __add__(self, rhs: "StrainSquared") -> "StrainSquared": ...
2103
+ def __sub__(self, rhs: "StrainSquared") -> "StrainSquared": ...
2104
+ @overload
2105
+ def __mul__(self, rhs: float) -> "StrainSquared": ...
2106
+ @overload
2107
+ def __mul__(self, rhs: Vector3) -> Vector3: ...
2108
+ @overload
2109
+ def __mul__(self, rhs: Any) -> Any: ...
2110
+ @overload
2111
+ def __truediv__(self, rhs: float) -> "StrainSquared": ...
2112
+ @overload
2113
+ def __truediv__(self, rhs: "Strain") -> "Strain": ...
2114
+ @overload
2115
+ def __truediv__(self, rhs: "StrainSquared") -> float: ...
2116
+ @overload
2117
+ def __truediv__(self, rhs: Any) -> Any: ...
2118
+ @overload
2119
+ def __mod__(self, rhs: float) -> "StrainSquared": ...
2120
+ @overload
2121
+ def __mod__(self, rhs: "Strain") -> "Strain": ...
2122
+ @overload
2123
+ def __mod__(self, rhs: "StrainSquared") -> float: ...
2124
+ @overload
2125
+ def __mod__(self, rhs: Any) -> Any: ...
2126
+ def __rmul__(self, rhs: float) -> "StrainSquared": ...
2127
+ def __repr__(self) -> str: ...
2128
+ def __str__(self) -> str: ...
2129
+ def sqrt(self) -> "Strain": ...
2130
+
2088
2131
  class StressUnit:
2089
2132
  Pa: ClassVar["StressUnit"]
2090
2133
  kPa: ClassVar["StressUnit"]
@@ -44,6 +44,18 @@ macro_rules! impl_quantity {
44
44
  pub(crate) kind_id: u32,
45
45
  }
46
46
 
47
+ impl core::hash::Hash for $type {
48
+ #[cfg(not(any(feature = "storage-f64", feature = "storage-f32")))]
49
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
50
+ core::hash::Hash::hash(&self.multiplier.to_bits(), state);
51
+ core::hash::Hash::hash(&self.power, state);
52
+ }
53
+ #[cfg(any(feature = "storage-f64", feature = "storage-f32"))]
54
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
55
+ core::hash::Hash::hash(&self.value.to_bits(), state);
56
+ }
57
+ }
58
+
47
59
  impl $type {
48
60
  #[cfg(not(any(feature = "storage-f64", feature = "storage-f32")))]
49
61
  fn from_parts(multiplier: f64, power: i32) -> Self {
@@ -119,6 +119,8 @@ pub mod quantities {
119
119
  pub use rotational_stiffness::*;
120
120
  pub mod strain;
121
121
  pub use strain::*;
122
+ pub mod strain_squared;
123
+ pub use strain_squared::*;
122
124
  pub mod stress;
123
125
  pub use stress::*;
124
126
  pub mod stress_cubed;
@@ -0,0 +1,36 @@
1
+ use crate::impl_macros::macros::*;
2
+
3
+ #[cfg_attr(feature = "strum", derive(EnumIter))]
4
+ #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
6
+ #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int, from_py_object))]
7
+ pub enum StrainSquaredUnit {
8
+ msq_msq,
9
+ }
10
+
11
+ impl StrainSquaredUnit {
12
+ pub const fn base_per_x_const(self) -> (f64, i32) {
13
+ match self {
14
+ StrainSquaredUnit::msq_msq => (1., 0),
15
+ }
16
+ }
17
+ }
18
+
19
+ impl PhysicsUnit for StrainSquaredUnit {
20
+ fn name(&self) -> &str {
21
+ match &self {
22
+ StrainSquaredUnit::msq_msq => "m²/m²",
23
+ }
24
+ }
25
+
26
+ fn base_per_x(&self) -> (f64, i32) {
27
+ (*self).base_per_x_const()
28
+ }
29
+ }
30
+
31
+ impl_quantity!(
32
+ StrainSquared,
33
+ StrainSquaredUnit,
34
+ [StrainSquaredUnit::msq_msq]
35
+ );
36
+ impl_div_with_self_to_f64!(StrainSquared);
@@ -82,6 +82,7 @@ impl_mul!(Stress, Strain, Stress);
82
82
  impl_mul_relation_with_self!(Distance, Area);
83
83
  impl_mul_relation_with_self!(Area, AreaOfMoment);
84
84
  impl_mul_relation_with_self!(InverseDistance, InverseArea);
85
+ impl_mul_relation_with_self!(Strain, StrainSquared);
85
86
  impl_mul_relation_with_self!(Stress, StressSquared);
86
87
  impl_mul_relation_with_other!(Stress, StressSquared, StressCubed);
87
88
  impl_div!(StressSquared, StressCubed, InverseStress);
@@ -6,6 +6,8 @@ use unitforge::quantities::{
6
6
  InverseStress, InverseStressUnit, Stress, StressSquared, StressSquaredUnit, StressUnit,
7
7
  };
8
8
  #[cfg(not(any(feature = "storage-f64", feature = "storage-f32")))]
9
+ use unitforge::quantities::{Strain, StrainSquaredUnit, StrainUnit};
10
+ #[cfg(not(any(feature = "storage-f64", feature = "storage-f32")))]
9
11
  use unitforge::Sqrt;
10
12
  use unitforge::{PhysicsQuantity, Quantity, Unit};
11
13
 
@@ -76,3 +78,14 @@ fn force_stress_from_stress_squared_times_area() {
76
78
 
77
79
  assert!(approx_eq(result.to(ForceStressUnit::Nsq_msq), 6.0, 1e-12));
78
80
  }
81
+
82
+ #[test]
83
+ #[cfg(not(any(feature = "storage-f64", feature = "storage-f32")))]
84
+ fn strain_squared_relations() {
85
+ let strain = Strain::new(2.0, StrainUnit::m_m);
86
+ let strain_squared = strain * strain;
87
+
88
+ assert_eq!(strain_squared.to(StrainSquaredUnit::msq_msq), 4.0);
89
+ assert_eq!(strain_squared / strain, strain);
90
+ assert_eq!(strain_squared.sqrt(), strain);
91
+ }
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "unitforge_macros"
3
- version = "0.5.4"
3
+ version = "0.5.6"
4
4
  edition = "2021"
5
5
  authors = ["Dr.Q team <info@askdrq.com>", "Henrik Stromberg <henrik@askdrq.com>"]
6
6
  description = "Proc macros for generating units, quantities, and Python bindings in unitforge"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes