unitforge 0.3.14__tar.gz → 0.3.16__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 (72) hide show
  1. {unitforge-0.3.14 → unitforge-0.3.16}/Cargo.lock +6 -6
  2. {unitforge-0.3.14 → unitforge-0.3.16}/Cargo.toml +4 -4
  3. {unitforge-0.3.14 → unitforge-0.3.16}/PKG-INFO +1 -1
  4. {unitforge-0.3.14 → unitforge-0.3.16}/src/impl_macros.rs +20 -8
  5. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/acceleration.rs +1 -15
  6. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/angle.rs +2 -14
  7. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/angular_acceleration.rs +1 -14
  8. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/angular_velocity.rs +1 -14
  9. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/area.rs +1 -15
  10. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/area_of_moment.rs +1 -14
  11. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/charge.rs +1 -14
  12. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/compliance.rs +1 -14
  13. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/density.rs +1 -14
  14. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/distance.rs +1 -14
  15. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force.rs +1 -14
  16. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_area.rs +1 -14
  17. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_distance.rs +1 -14
  18. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_div_distance_power_four.rs +1 -14
  19. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_per_volume.rs +1 -14
  20. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_stress.rs +1 -14
  21. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/force_volume.rs +1 -14
  22. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/inverse_area.rs +1 -14
  23. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/inverse_distance.rs +1 -14
  24. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/inverse_stress.rs +1 -14
  25. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/mass.rs +1 -14
  26. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/mass_div_time_squared_volume.rs +1 -14
  27. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/mass_per_distance.rs +1 -14
  28. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/rotational_stiffness.rs +1 -14
  29. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/stiffness.rs +1 -14
  30. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/strain.rs +1 -14
  31. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/stress.rs +1 -14
  32. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/stress_squared.rs +1 -14
  33. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/time.rs +1 -14
  34. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/velocity.rs +1 -14
  35. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/velocity_squared.rs +1 -14
  36. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/voltage.rs +1 -14
  37. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities/volume.rs +1 -14
  38. {unitforge-0.3.14 → unitforge-0.3.16}/src/tests/quantity_unit_tests.rs +8 -3
  39. {unitforge-0.3.14 → unitforge-0.3.16}/unitforge_macros/Cargo.toml +1 -1
  40. {unitforge-0.3.14 → unitforge-0.3.16}/unitforge_macros/src/lib.rs +11 -8
  41. {unitforge-0.3.14 → unitforge-0.3.16}/.gitignore +0 -0
  42. {unitforge-0.3.14 → unitforge-0.3.16}/.gitlab-ci.yml +0 -0
  43. {unitforge-0.3.14 → unitforge-0.3.16}/Readme.md +0 -0
  44. {unitforge-0.3.14 → unitforge-0.3.16}/Readme_py.md +0 -0
  45. {unitforge-0.3.14 → unitforge-0.3.16}/pyproject.toml +0 -0
  46. {unitforge-0.3.14 → unitforge-0.3.16}/python/unitforge/__init__.py +0 -0
  47. {unitforge-0.3.14 → unitforge-0.3.16}/scripts/generate_python_stubs.py +0 -0
  48. {unitforge-0.3.14 → unitforge-0.3.16}/src/lib.rs +0 -0
  49. {unitforge-0.3.14 → unitforge-0.3.16}/src/prelude.rs +0 -0
  50. {unitforge-0.3.14 → unitforge-0.3.16}/src/quantities.template.rs +0 -0
  51. {unitforge-0.3.14 → unitforge-0.3.16}/src/relations.rs +0 -0
  52. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/bindings/matrix3_py.template.rs +0 -0
  53. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/bindings/vector3_py.template.rs +0 -0
  54. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/matrix2.rs +0 -0
  55. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/matrix2x3.rs +0 -0
  56. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/matrix3.rs +0 -0
  57. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/matrix3x2.rs +0 -0
  58. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/vector2.rs +0 -0
  59. {unitforge-0.3.14 → unitforge-0.3.16}/src/small_linalg/vector3.rs +0 -0
  60. {unitforge-0.3.14 → unitforge-0.3.16}/src/tests/serde_tests.rs +0 -0
  61. {unitforge-0.3.14 → unitforge-0.3.16}/tests/matrix2.rs +0 -0
  62. {unitforge-0.3.14 → unitforge-0.3.16}/tests/matrix2x3.rs +0 -0
  63. {unitforge-0.3.14 → unitforge-0.3.16}/tests/matrix3.rs +0 -0
  64. {unitforge-0.3.14 → unitforge-0.3.16}/tests/matrix3x2.rs +0 -0
  65. {unitforge-0.3.14 → unitforge-0.3.16}/tests/ndarray_dot.rs +0 -0
  66. {unitforge-0.3.14 → unitforge-0.3.16}/tests/quantities.rs +0 -0
  67. {unitforge-0.3.14 → unitforge-0.3.16}/tests/small_linalg_interfaces.rs +0 -0
  68. {unitforge-0.3.14 → unitforge-0.3.16}/tests/test_quantities.py +0 -0
  69. {unitforge-0.3.14 → unitforge-0.3.16}/tests/test_small_linalg.py +0 -0
  70. {unitforge-0.3.14 → unitforge-0.3.16}/tests/typecheck/mypy_smoke.py +0 -0
  71. {unitforge-0.3.14 → unitforge-0.3.16}/tests/vector2.rs +0 -0
  72. {unitforge-0.3.14 → unitforge-0.3.16}/tests/vector3.rs +0 -0
@@ -322,15 +322,15 @@ dependencies = [
322
322
 
323
323
  [[package]]
324
324
  name = "strum"
325
- version = "0.27.2"
325
+ version = "0.28.0"
326
326
  source = "registry+https://github.com/rust-lang/crates.io-index"
327
- checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf"
327
+ checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
328
328
 
329
329
  [[package]]
330
330
  name = "strum_macros"
331
- version = "0.27.2"
331
+ version = "0.28.0"
332
332
  source = "registry+https://github.com/rust-lang/crates.io-index"
333
- checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7"
333
+ checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
334
334
  dependencies = [
335
335
  "heck",
336
336
  "proc-macro2",
@@ -369,7 +369,7 @@ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
369
369
 
370
370
  [[package]]
371
371
  name = "unitforge"
372
- version = "0.3.14"
372
+ version = "0.3.16"
373
373
  dependencies = [
374
374
  "ndarray",
375
375
  "num-traits",
@@ -384,7 +384,7 @@ dependencies = [
384
384
 
385
385
  [[package]]
386
386
  name = "unitforge_macros"
387
- version = "0.3.14"
387
+ version = "0.3.16"
388
388
  dependencies = [
389
389
  "regex",
390
390
  ]
@@ -4,7 +4,7 @@ crate-type = ["cdylib", "rlib"]
4
4
 
5
5
  [package]
6
6
  name = "unitforge"
7
- version = "0.3.14"
7
+ version = "0.3.16"
8
8
  edition = "2021"
9
9
  authors = ["Dr.Q team <info@askdrq.com>", "Henrik Stromberg <henrik@askdrq.com>"]
10
10
  description = "A library for unit and quantity consistent computations in Rust"
@@ -21,9 +21,9 @@ serde = { version = "1", optional = true, features = ["derive"] }
21
21
  serde_json = { version = "1.0.140", optional = true }
22
22
  pyo3 = { version = "0.26.0", features = ["extension-module", "auto-initialize", "multiple-pymethods"], optional = true }
23
23
  numpy = { version = "0.26.0", optional = true }
24
- strum = { version = "0.27.2", optional = true }
25
- strum_macros = { version = "0.27.2", optional = true }
26
- unitforge_macros = { version = "0.3.14", path = "unitforge_macros" }
24
+ strum = { version = "0.28.0", optional = true }
25
+ strum_macros = { version = "0.28.0", optional = true }
26
+ unitforge_macros = { version = "0.3.16", path = "unitforge_macros" }
27
27
 
28
28
  [features]
29
29
  serde = ["dep:serde", "dep:serde_json", "ndarray/serde"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitforge
3
- Version: 0.3.14
3
+ Version: 0.3.16
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,6 +1,19 @@
1
1
  #[macro_export]
2
2
  macro_rules! impl_quantity {
3
3
  ($type:ident, $unit:ident, $display_units:expr) => {
4
+ use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
+ use num_traits::Zero;
6
+ use num_traits::{Float, FromPrimitive};
7
+ #[cfg(feature = "serde")]
8
+ use serde::{Deserialize, Serialize};
9
+ use std::cmp::Ordering;
10
+ use std::collections::HashSet;
11
+ use std::fmt;
12
+ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
+ use $crate::prelude::*;
14
+
15
+ #[cfg(feature = "pyo3")]
16
+ use pyo3::pyclass;
4
17
  #[cfg(feature = "pyo3")]
5
18
  use pyo3::{
6
19
  basic::CompareOp, exceptions::PyValueError, pymethods, types::PyType, Bound,
@@ -8,7 +21,7 @@ macro_rules! impl_quantity {
8
21
  };
9
22
 
10
23
  #[cfg(feature = "strum")]
11
- use strum::IntoEnumIterator;
24
+ use strum_macros::EnumIter;
12
25
  use $crate::small_linalg::{Matrix3, Vector3};
13
26
  #[cfg(feature = "pyo3")]
14
27
  use $crate::Quantity;
@@ -579,15 +592,14 @@ macro_rules! impl_quantity {
579
592
  }
580
593
  }
581
594
 
582
- #[cfg(feature = "strum")]
583
595
  impl $type {
584
- pub fn optimal_unit(&self) -> Option<$unit> {
585
- let mut min_value = f64::INFINITY;
596
+ pub fn optimal_unit(&self, choices: HashSet<$unit>) -> Option<$unit> {
597
+ let mut min_value = i32::MAX;
586
598
  let mut best_unit = None;
587
- for unit in $unit::iter() {
588
- let deviation = (self.to(unit).abs() - 1.).abs();
589
- if deviation < min_value {
590
- min_value = deviation;
599
+ for unit in choices {
600
+ let difference = (self.power - unit.base_per_x().1).abs();
601
+ if difference < min_value {
602
+ min_value = difference;
591
603
  best_unit = Some(unit);
592
604
  }
593
605
  }
@@ -1,22 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
-
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
2
 
17
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
7
  pub enum AccelerationUnit {
22
8
  m_ssq,
@@ -1,23 +1,11 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::PhysicsUnit;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FloatConst, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
3
+ use num_traits::FloatConst;
12
4
  use std::f64::consts::PI;
13
- use std::fmt;
14
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
15
- #[cfg(feature = "strum")]
16
- use strum_macros::EnumIter;
17
5
 
18
6
  #[cfg_attr(feature = "strum", derive(EnumIter))]
19
7
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20
- #[derive(Copy, Clone, PartialEq, Debug)]
8
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
21
9
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
22
10
  pub enum AngleUnit {
23
11
  rad,
@@ -1,23 +1,10 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::PhysicsUnit;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
3
  use std::f64::consts::PI;
13
- use std::fmt;
14
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
15
- #[cfg(feature = "strum")]
16
- use strum_macros::EnumIter;
17
4
 
18
5
  #[cfg_attr(feature = "strum", derive(EnumIter))]
19
6
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20
- #[derive(Copy, Clone, PartialEq, Debug)]
7
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
21
8
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
22
9
  pub enum AngularAccelerationUnit {
23
10
  rad_ssq,
@@ -1,23 +1,10 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::PhysicsUnit;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
3
  use std::f64::consts::PI;
13
- use std::fmt;
14
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
15
- #[cfg(feature = "strum")]
16
- use strum_macros::EnumIter;
17
4
 
18
5
  #[cfg_attr(feature = "strum", derive(EnumIter))]
19
6
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20
- #[derive(Copy, Clone, PartialEq, Debug)]
7
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
21
8
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
22
9
  pub enum AngularVelocityUnit {
23
10
  rad_s,
@@ -1,22 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
-
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
2
 
17
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
7
  pub enum AreaUnit {
22
8
  kmsq,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum AreaOfMomentUnit {
21
8
  mhc,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ChargeUnit {
21
8
  C,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ComplianceUnit {
21
8
  m_N,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum DensityUnit {
21
8
  kg_dmcb,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum DistanceUnit {
22
9
  km,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForceUnit {
21
8
  GN,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForceAreaUnit {
21
8
  Nmsq,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum ForceDistanceUnit {
22
9
  Nm,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForcePerDistancePowerFourUnit {
21
8
  N_mmhc,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForcePerVolumeUnit {
21
8
  N_mcb,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForceStressUnit {
21
8
  Nsq_msq,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum ForceVolumeUnit {
21
8
  Nmcb,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::Area;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum InverseAreaUnit {
22
9
  _msq,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum InverseDistanceUnit {
22
9
  _km,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::Stress;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum InverseStressUnit {
22
9
  _Pa,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum MassUnit {
22
9
  mg,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum MassDivTimeSquaredVolumeUnit {
21
8
  kg_ssqmq,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum MassPerDistanceUnit {
21
8
  kg_m,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::PhysicsUnit;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum RotationalStiffnessUnit {
22
9
  Nmm_deg,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::PhysicsUnit;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum StiffnessUnit {
22
9
  N_mm,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::{Distance, PhysicsUnit, Stress};
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum StrainUnit {
22
9
  m_m,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum StressUnit {
22
9
  Pa,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum StressSquaredUnit {
21
8
  Nsq_mmhc,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum TimeUnit {
21
8
  ns,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum VelocityUnit {
21
8
  km_s,
@@ -1,22 +1,9 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
2
  use crate::quantities::*;
4
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
5
- use num_traits::identities::Zero;
6
- use num_traits::{Float, FromPrimitive};
7
- #[cfg(feature = "pyo3")]
8
- use pyo3::pyclass;
9
- #[cfg(feature = "serde")]
10
- use serde::{Deserialize, Serialize};
11
- use std::cmp::Ordering;
12
- use std::fmt;
13
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
14
- #[cfg(feature = "strum")]
15
- use strum_macros::EnumIter;
16
3
 
17
4
  #[cfg_attr(feature = "strum", derive(EnumIter))]
18
5
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
- #[derive(Copy, Clone, PartialEq, Debug)]
6
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
20
7
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
21
8
  pub enum VelocitySquaredUnit {
22
9
  msq_ssq,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum VoltageUnit {
21
8
  V,
@@ -1,21 +1,8 @@
1
1
  use crate::impl_macros::macros::*;
2
- use crate::prelude::*;
3
- use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4
- use num_traits::identities::Zero;
5
- use num_traits::{Float, FromPrimitive};
6
- #[cfg(feature = "pyo3")]
7
- use pyo3::pyclass;
8
- #[cfg(feature = "serde")]
9
- use serde::{Deserialize, Serialize};
10
- use std::cmp::Ordering;
11
- use std::fmt;
12
- use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13
- #[cfg(feature = "strum")]
14
- use strum_macros::EnumIter;
15
2
 
16
3
  #[cfg_attr(feature = "strum", derive(EnumIter))]
17
4
  #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18
- #[derive(Copy, Clone, PartialEq, Debug)]
5
+ #[derive(Copy, Clone, PartialEq, Debug, Hash, Eq)]
19
6
  #[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20
7
  pub enum VolumeUnit {
21
8
  kmcb,
@@ -101,11 +101,16 @@ mod tests {
101
101
  assert!((result.to(ForceStressUnit::Nsq_msq) - 6.0).abs() < 1E-12);
102
102
  }
103
103
 
104
- #[cfg(feature = "strum")]
105
104
  #[test]
106
- fn test_optimal_unit() {
105
+ fn test_optimal_unit_with_selection() {
107
106
  let area = Area::new(0.0001, AreaUnit::msq);
108
- let optimal_unit = area.optimal_unit().unwrap();
107
+ let optimal_unit = area
108
+ .optimal_unit(
109
+ vec![AreaUnit::kmsq, AreaUnit::cmsq, AreaUnit::nmsq]
110
+ .into_iter()
111
+ .collect::<std::collections::HashSet<_>>(),
112
+ )
113
+ .unwrap();
109
114
  assert_eq!(optimal_unit, AreaUnit::cmsq)
110
115
  }
111
116
  }
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "unitforge_macros"
3
- version = "0.3.14"
3
+ version = "0.3.16"
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"
@@ -241,7 +241,9 @@ fn parse_unit_variants(files: &[String], unit_name: &str) -> Result<Vec<String>,
241
241
  }
242
242
  }
243
243
 
244
- Err(format!("Enum {unit_name} not found in quantity source files"))
244
+ Err(format!(
245
+ "Enum {unit_name} not found in quantity source files"
246
+ ))
245
247
  }
246
248
 
247
249
  fn fnv1a32(input: &str) -> u32 {
@@ -443,12 +445,10 @@ fn write_quantity_code(
443
445
  let mut id_to_variant_match = String::new();
444
446
  for variant_name in unit_variant_list {
445
447
  let variant_id = stable_unit_variant_id(&unit_name, variant_name);
446
- variant_to_id_match += &format!(
447
- " {struct_name}Unit::{variant_name} => {variant_id},\n"
448
- );
449
- id_to_variant_match += &format!(
450
- " {variant_id} => Some({struct_name}Unit::{variant_name}),\n"
451
- );
448
+ variant_to_id_match +=
449
+ &format!(" {struct_name}Unit::{variant_name} => {variant_id},\n");
450
+ id_to_variant_match +=
451
+ &format!(" {variant_id} => Some({struct_name}Unit::{variant_name}),\n");
452
452
  }
453
453
  unit_variant_id_impls += &format!(
454
454
  "impl pyo3_capsule_api::UnitVariantId for {struct_name}Unit {{\n fn to_variant_id(self) -> i32 {{\n match self {{\n{variant_to_id_match} }}\n }}\n fn from_variant_id(variant_id: i32) -> Option<Self> {{\n match variant_id {{\n{id_to_variant_match} _ => None,\n }}\n }}\n}}\n"
@@ -559,7 +559,10 @@ fn write_quantity_code(
559
559
  .replace("// __UNIT_KIND_ID_IMPLS__", &unit_kind_id_impls)
560
560
  .replace("// __UNIT_VARIANT_ID_IMPLS__", &unit_variant_id_impls)
561
561
  .replace("// __QUANTITY_TO_REPR_MATCHES__", &quantity_to_repr_matches)
562
- .replace("// __QUANTITY_FROM_REPR_MATCHES__", &quantity_from_repr_matches)
562
+ .replace(
563
+ "// __QUANTITY_FROM_REPR_MATCHES__",
564
+ &quantity_from_repr_matches,
565
+ )
563
566
  .replace("// __UNIT_TO_REPR_MATCHES__", &unit_to_repr_matches)
564
567
  .replace("// __UNIT_FROM_REPR_MATCHES__", &unit_from_repr_matches)
565
568
  .replace("// __UNIT_TO_PYOBJECT_MATCHES__", &unit_to_pyobject_matches))
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