diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d00817..296e338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Changes in each release are listed below. +## 1.7.2 ??????????? + +* Fixed pyo3 decorators to allow stub_gen to work properly- generating python stubs correctly. +* (TODO) - used new future version of pyo3_stub_gen to ensure Chrono::FixedTimeOffset can have a stub generated in `MetafitsContext`. + ## 1.7.1 23-Oct-2024 * Release to fix issue generating Rust docs. diff --git a/Cargo.toml b/Cargo.toml index 6f1cec5..955f59c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mwalib" -version = "1.7.1" +version = "1.7.2" homepage = "https://github.com/MWATelescope/mwalib" repository = "https://github.com/MWATelescope/mwalib" readme = "README.md" diff --git a/src/antenna/mod.rs b/src/antenna/mod.rs index 29f0eed..c771334 100644 --- a/src/antenna/mod.rs +++ b/src/antenna/mod.rs @@ -7,6 +7,8 @@ use crate::rfinput::*; use std::fmt; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; @@ -14,8 +16,7 @@ use pyo3_stub_gen_derive::gen_stub_pyclass; mod test; /// Structure for storing MWA antennas (tiles without polarisation) information from the metafits file -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct Antenna { /// This is the antenna number. diff --git a/src/baseline/mod.rs b/src/baseline/mod.rs index 714043f..f716adf 100644 --- a/src/baseline/mod.rs +++ b/src/baseline/mod.rs @@ -7,14 +7,16 @@ use crate::misc; use std::fmt; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; #[cfg(test)] mod test; + /// This is a struct for our baselines, so callers know the antenna ordering -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct Baseline { /// Index in the mwalibContext.antenna array for antenna1 for this baseline diff --git a/src/coarse_channel/mod.rs b/src/coarse_channel/mod.rs index 2388fad..48307e4 100644 --- a/src/coarse_channel/mod.rs +++ b/src/coarse_channel/mod.rs @@ -11,6 +11,8 @@ use crate::*; use error::CoarseChannelError; use std::fmt; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; @@ -18,8 +20,7 @@ use pyo3_stub_gen_derive::gen_stub_pyclass; mod test; /// This is a struct for coarse channels -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct CoarseChannel { /// Correlator channel is 0 indexed (0..N-1) diff --git a/src/convert/mod.rs b/src/convert/mod.rs index 7ea5c2c..15f4a8c 100644 --- a/src/convert/mod.rs +++ b/src/convert/mod.rs @@ -12,6 +12,11 @@ use crate::rfinput::*; use log::trace; use std::fmt; +#[cfg(feature = "python")] +use pyo3::prelude::*; +#[cfg(feature = "python")] +use pyo3_stub_gen_derive::gen_stub_pyclass; + #[cfg(test)] mod test; @@ -35,8 +40,8 @@ fn fine_pfb_reorder(input: usize) -> usize { } /// Structure for storing where in the input visibilities to get the specified baseline when converting +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] pub(crate) struct LegacyConversionBaseline { pub baseline: usize, // baseline index pub ant1: usize, // antenna1 index diff --git a/src/correlator_context/mod.rs b/src/correlator_context/mod.rs index 816f4b5..3f6dc31 100644 --- a/src/correlator_context/mod.rs +++ b/src/correlator_context/mod.rs @@ -16,9 +16,10 @@ use crate::metafits_context::*; use crate::timestep::*; use crate::*; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; - #[cfg(feature = "python")] mod python; @@ -28,8 +29,7 @@ mod test; /// /// This represents the basic metadata and methods for an MWA correlator observation. /// -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Debug)] pub struct CorrelatorContext { /// Observation Metadata obtained from the metafits file diff --git a/src/gpubox_files/mod.rs b/src/gpubox_files/mod.rs index e513ca5..00c654e 100644 --- a/src/gpubox_files/mod.rs +++ b/src/gpubox_files/mod.rs @@ -18,6 +18,8 @@ use regex::Regex; use crate::*; pub use error::GpuboxError; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; @@ -35,8 +37,7 @@ pub(crate) struct ObsTimesAndChans { /// This represents one group of gpubox files with the same "batch" identitifer. /// e.g. obsid_datetime_chan_batch -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct GpuBoxBatch { /// Batch number: 00,01,02..n. @@ -66,8 +67,7 @@ impl fmt::Debug for GpuBoxBatch { } /// This represents one gpubox file -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct GpuBoxFile { /// Filename of gpubox file diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index 7ce8487..b6b5374 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -26,6 +26,8 @@ pub mod error; #[cfg(test)] mod test; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; #[cfg(feature = "python")] @@ -345,8 +347,7 @@ impl std::str::FromStr for MWAMode { /// /// Metafits context. This represents the basic metadata for an MWA observation. /// -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone, Debug)] pub struct MetafitsContext { /// mwa version diff --git a/src/timestep/mod.rs b/src/timestep/mod.rs index 0e562f8..341dd7a 100644 --- a/src/timestep/mod.rs +++ b/src/timestep/mod.rs @@ -14,13 +14,14 @@ use std::fmt; #[cfg(test)] mod test; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; /// This is a struct for our timesteps /// NOTE: correlator timesteps use unix time, voltage timesteps use gpstime, but we convert the two depending on what we are given -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct TimeStep { /// UNIX time (in milliseconds to avoid floating point inaccuracy) diff --git a/src/voltage_context/mod.rs b/src/voltage_context/mod.rs index e3379d8..de1a37a 100644 --- a/src/voltage_context/mod.rs +++ b/src/voltage_context/mod.rs @@ -15,6 +15,8 @@ use std::fs::File; use std::io::{Read, Seek, SeekFrom}; use std::path::Path; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; @@ -27,8 +29,7 @@ pub(crate) mod test; // It's pub crate because I reuse some test code in the ffi /// /// This represents the basic metadata and methods for an MWA voltage capture system (VCS) observation. /// -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Debug)] pub struct VoltageContext { /// Observation Metadata obtained from the metafits file diff --git a/src/voltage_files/mod.rs b/src/voltage_files/mod.rs index 141e1ac..07717f8 100644 --- a/src/voltage_files/mod.rs +++ b/src/voltage_files/mod.rs @@ -14,6 +14,8 @@ use std::collections::HashSet; use std::fmt; use std::path::Path; +#[cfg(feature = "python")] +use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3_stub_gen_derive::gen_stub_pyclass; @@ -32,8 +34,7 @@ pub(crate) struct ObsTimesAndChans { /// e.g. /// MWA Legacy: obsid_gpstime_datetime_chan /// MWAX : obsid_gpstime_datetime_chan -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct VoltageFileBatch { // GPS second of this observation. e.g. 1234567890 @@ -63,8 +64,7 @@ impl fmt::Debug for VoltageFileBatch { } /// This represents one voltage file -#[cfg_attr(feature = "python", gen_stub_pyclass)] -#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))] +#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] #[derive(Clone)] pub struct VoltageFile { /// Filename of voltage file