Skip to content

Commit 4595d8f

Browse files
committed
Added first experimental pyo3 feature for context and baseline only. NOTE bug in pyo3 is blocking use of feature: PyO3/pyo3#780
1 parent 519ef4a commit 4595d8f

19 files changed

+234
-19
lines changed

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ license = "MPL-2.0"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

12+
13+
[features]
14+
default = []
15+
python = ["pyo3", "numpy"]
16+
1217
[profile.release]
1318
lto = true
1419
codegen-units = 1 # Set this to 1 in Cargo.toml to allow for maximum size reduction optimizations
@@ -28,6 +33,9 @@ rayon = "1.4.*"
2833
regex = "1.3.*"
2934
thiserror = "1.0.*"
3035

36+
pyo3 = { version = "0.12.*", features = ["extension-module"], optional = true }
37+
numpy = { version = "0.12.*", optional = true }
38+
3139
[dev-dependencies]
3240
anyhow = "1.0.*"
3341
criterion = "0.3.*"

src/antenna.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This Source Code Form is subject to the terms of the Mozilla Public
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#![warn(clippy::all)]
45

56
/*!
67
Structs and helper methods for antenna metadata

src/baseline.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
// This Source Code Form is subject to the terms of the Mozilla Public
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#![warn(clippy::all)]
45

56
/*!
67
Structs and helper methods for baseline metadata
78
*/
89
use crate::misc;
910
use std::fmt;
1011

12+
#[cfg(feature = "python")]
13+
use pyo3::prelude::*;
14+
1115
/// This is a struct for our baselines, so callers know the antenna ordering
1216
#[allow(non_camel_case_types)]
17+
#[cfg_attr(feature = "python", pyclass)]
1318
#[derive(Clone)]
1419
pub struct mwalibBaseline {
1520
/// Index in the mwalibContext.antenna array for antenna1 for this baseline
21+
#[cfg_attr(feature = "python", pyo3(get, set))]
1622
pub antenna1_index: usize,
1723
/// Index in the mwalibContext.antenna array for antenna2 for this baseline
24+
#[cfg_attr(feature = "python", pyo3(get, set))]
1825
pub antenna2_index: usize,
1926
}
2027

@@ -54,6 +61,14 @@ impl mwalibBaseline {
5461
}
5562
}
5663

64+
#[cfg_attr(feature = "python", pymethods)]
65+
impl mwalibBaseline {
66+
#[cfg(feature = "python")]
67+
pub fn py_populate_baselines(&mut self, num_antennas: usize) -> PyResult<Vec<Self>> {
68+
Ok(mwalibBaseline::populate_baselines(num_antennas))
69+
}
70+
}
71+
5772
/// Implements fmt::Debug for mwalibBaseline struct
5873
///
5974
/// # Arguments

src/coarse_channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This Source Code Form is subject to the terms of the Mozilla Public
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#![warn(clippy::all)]
45

56
/*!
67
Structs and helper methods for coarse channel metadata

0 commit comments

Comments
 (0)