Skip to content

Commit

Permalink
Added first experimental pyo3 feature for context and baseline only. …
Browse files Browse the repository at this point in the history
…NOTE bug in pyo3 is blocking use of feature: PyO3/pyo3#780
  • Loading branch information
gsleap committed Nov 9, 2020
1 parent 519ef4a commit 4595d8f
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 19 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ license = "MPL-2.0"

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


[features]
default = []
python = ["pyo3", "numpy"]

[profile.release]
lto = true
codegen-units = 1 # Set this to 1 in Cargo.toml to allow for maximum size reduction optimizations
Expand All @@ -28,6 +33,9 @@ rayon = "1.4.*"
regex = "1.3.*"
thiserror = "1.0.*"

pyo3 = { version = "0.12.*", features = ["extension-module"], optional = true }
numpy = { version = "0.12.*", optional = true }

[dev-dependencies]
anyhow = "1.0.*"
criterion = "0.3.*"
Expand Down
1 change: 1 addition & 0 deletions src/antenna.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![warn(clippy::all)]

/*!
Structs and helper methods for antenna metadata
Expand Down
15 changes: 15 additions & 0 deletions src/baseline.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![warn(clippy::all)]

/*!
Structs and helper methods for baseline metadata
*/
use crate::misc;
use std::fmt;

#[cfg(feature = "python")]
use pyo3::prelude::*;

/// This is a struct for our baselines, so callers know the antenna ordering
#[allow(non_camel_case_types)]
#[cfg_attr(feature = "python", pyclass)]
#[derive(Clone)]
pub struct mwalibBaseline {
/// Index in the mwalibContext.antenna array for antenna1 for this baseline
#[cfg_attr(feature = "python", pyo3(get, set))]
pub antenna1_index: usize,
/// Index in the mwalibContext.antenna array for antenna2 for this baseline
#[cfg_attr(feature = "python", pyo3(get, set))]
pub antenna2_index: usize,
}

Expand Down Expand Up @@ -54,6 +61,14 @@ impl mwalibBaseline {
}
}

#[cfg_attr(feature = "python", pymethods)]
impl mwalibBaseline {
#[cfg(feature = "python")]
pub fn py_populate_baselines(&mut self, num_antennas: usize) -> PyResult<Vec<Self>> {
Ok(mwalibBaseline::populate_baselines(num_antennas))
}
}

/// Implements fmt::Debug for mwalibBaseline struct
///
/// # Arguments
Expand Down
1 change: 1 addition & 0 deletions src/coarse_channel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![warn(clippy::all)]

/*!
Structs and helper methods for coarse channel metadata
Expand Down
Loading

0 comments on commit 4595d8f

Please sign in to comment.