differt-core 0.0.2__tar.gz → 0.0.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: differt-core
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -16,4 +16,4 @@ name = "differt_core"
16
16
  [package]
17
17
  edition = "2021"
18
18
  name = "differt-core"
19
- version = "0.0.2"
19
+ version = "0.0.3"
@@ -4,30 +4,26 @@ use pyo3::prelude::*;
4
4
 
5
5
  /// Formats the sum of two numbers as string.
6
6
  #[pyfunction]
7
- fn generate_path_candidates(
8
- py: Python<'_>,
9
- num_primitives: usize,
10
- order: usize,
11
- ) -> &PyArray2<usize> {
7
+ fn generate_path_candidates(py: Python<'_>, num_primitives: u32, order: u32) -> &PyArray2<u32> {
12
8
  if num_primitives == 0 || order == 0 {
13
9
  return Array2::default((0, 0)).into_pyarray(py);
14
10
  } else if order == 1 {
15
- let mut path_candidates = Array2::default((1, num_primitives));
11
+ let mut path_candidates = Array2::default((1, num_primitives as usize));
16
12
 
17
13
  for i in 0..num_primitives {
18
- path_candidates[(0, i)] = i;
14
+ path_candidates[(0, i as usize)] = i;
19
15
  }
20
16
  return path_candidates.into_pyarray(py);
21
17
  }
22
- let num_choices = num_primitives - 1;
23
- let num_candidates_per_batch = num_choices.pow((order - 1) as u32);
24
- let num_candidates = num_primitives * num_candidates_per_batch;
18
+ let num_choices = (num_primitives - 1) as usize;
19
+ let num_candidates_per_batch = num_choices.pow(order - 1);
20
+ let num_candidates = (num_primitives as usize) * num_candidates_per_batch;
25
21
 
26
- let mut path_candidates = Array2::default((order, num_candidates));
22
+ let mut path_candidates = Array2::default((order as usize, num_candidates));
27
23
  let mut batch_size = num_candidates_per_batch;
28
24
  let mut fill_value = 0;
29
25
 
30
- for i in 0..order {
26
+ for i in 0..(order as usize) {
31
27
  for j in (0..num_candidates).step_by(batch_size) {
32
28
  if i > 0 && fill_value == path_candidates[(i - 1, j)] {
33
29
  fill_value = (fill_value + 1) % num_primitives;
@@ -59,16 +55,16 @@ mod tests {
59
55
 
60
56
  use pyo3::{types::IntoPyDict, Python};
61
57
 
62
- #[rstest] // TODO: FIXME on Windows because uint is not consistent
63
- #[case(0, 0, "np.empty((0, 0), dtype=np.uint)")]
64
- #[case(3, 0, "np.empty((0, 0), dtype=np.uint)")]
65
- #[case(0, 3, "np.empty((0, 0), dtype=np.uint)")]
66
- #[case(9, 1, "np.arange(9, dtype=np.uint).reshape(1, 9)")]
67
- #[case(3, 1, "np.array([[0, 1, 2]], dtype=np.uint)")]
58
+ #[rstest]
59
+ #[case(0, 0, "np.empty((0, 0), dtype=np.uint32)")]
60
+ #[case(3, 0, "np.empty((0, 0), dtype=np.uint32)")]
61
+ #[case(0, 3, "np.empty((0, 0), dtype=np.uint32)")]
62
+ #[case(9, 1, "np.arange(9, dtype=np.uint32).reshape(1, 9)")]
63
+ #[case(3, 1, "np.array([[0, 1, 2]], dtype=np.uint32)")]
68
64
  #[case(
69
65
  3,
70
66
  2,
71
- "np.array([[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]], dtype=np.uint).T"
67
+ "np.array([[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]], dtype=np.uint32).T"
72
68
  )]
73
69
  #[case(
74
70
  3,
@@ -87,19 +83,19 @@ mod tests {
87
83
  [2, 0, 1],
88
84
  [2, 1, 2],
89
85
  [2, 1, 0],
90
- ], dtype=np.uint
86
+ ], dtype=np.uint32
91
87
  ).T"
92
88
  )]
93
89
  fn test_generate_path_candidates(
94
- #[case] num_primitives: usize,
95
- #[case] order: usize,
90
+ #[case] num_primitives: u32,
91
+ #[case] order: u32,
96
92
  #[case] code: &str,
97
93
  ) {
98
94
  Python::with_gil(|py| {
99
95
  let np = py.import("numpy").unwrap();
100
96
  let locals = [("np", np)].into_py_dict(py);
101
97
  let got = generate_path_candidates(py, num_primitives, order);
102
- let expected: &PyArray2<usize> = py
98
+ let expected: &PyArray2<u32> = py
103
99
  .eval(code, Some(locals), None)
104
100
  .unwrap()
105
101
  .extract()
File without changes
File without changes