Skip to content

Commit

Permalink
Fixed pyo3 stub decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
gsleap committed Oct 24, 2024
1 parent dded90b commit 470f084
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 3 additions & 2 deletions src/antenna/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
use crate::rfinput::*;
use std::fmt;

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

#[cfg(test)]
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.
Expand Down
6 changes: 4 additions & 2 deletions src/baseline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/coarse_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ 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;

#[cfg(test)]
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)
Expand Down
7 changes: 6 additions & 1 deletion src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/correlator_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/gpubox_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/metafits_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/timestep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/voltage_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/voltage_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 470f084

Please sign in to comment.