Skip to content

Commit

Permalink
Merge pull request #70 from MWATelescope/shao_rx
Browse files Browse the repository at this point in the history
SHAO, EDA2 receiver types, plus MacOS 14 Arm64 release and tests
  • Loading branch information
gsleap authored Apr 12, 2024
2 parents 13c2cce + a24e089 commit 3823218
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 39 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ jobs:
env:
DEBIAN_FRONTEND: noninteractive

- name: Install cfitsio
run: ./.github/workflows/make_cfitsio.sh
shell: bash
- name: install cfitsio
env:
# TODO: CFITSIO_VERSION: 4.4.0
CFITSIO_VERSION: 3.49
run: |
cd /tmp
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz
tar -xf cfitsio.tar.gz
rm cfitsio.tar.gz
cd cfitsio-${CFITSIO_VERSION}
./configure --prefix=/usr/local --enable-reentrant --disable-curl
sudo make shared
sudo make install
cd ..
sudo ldconfig
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -49,10 +62,10 @@ jobs:
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"

- name: Generate test lcov coverage into coverage/ dir
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: install maturin
run: |
python -m pip install --upgrade pip
python -m pip install maturin # [patchelf] ?
python -m pip install maturin
- name: build mwalib
run: |
Expand Down
58 changes: 40 additions & 18 deletions .github/workflows/run_python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,48 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, macOS-14]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
exclude:
- os: macOS-14
python-version: 3.8
- os: macOS-14
python-version: 3.9
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install cfitsio
run: ./.github/workflows/make_cfitsio.sh
shell: bash
uses: actions/checkout@v4

- name: (macos) install automake and autoconf
if: ${{ startsWith(matrix.os, 'macOS') }}
run: |
brew install automake autoconf
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: install cfitsio
env:
# TODO: CFITSIO_VERSION: 4.4.0
CFITSIO_VERSION: 3.49
run: |
cd /tmp
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz
tar -xf cfitsio.tar.gz
rm cfitsio.tar.gz
cd cfitsio-${CFITSIO_VERSION}
./configure --prefix=/usr/local --enable-reentrant --disable-curl
sudo make shared
sudo make install
cd ..
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo ldconfig
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -44,18 +69,15 @@ jobs:
- name: Run rust tests to generate test data
run: cargo test --features=cfitsio-static

- name: Run pytests
- name: Setup python environment and run pytests
run: |
pip3 install --upgrade pip
python3 -m venv env
source env/bin/activate
pip3 install maturin==1.3.2
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install automake
fi
pip3 install --upgrade pip
python3 -m venv env
source env/bin/activate
pip3 install --upgrade pip
pip3 install maturin==1.3.2
maturin develop --features=python,cfitsio-static --strip
maturin develop --features=python,cfitsio-static --strip
pip install pytest
pytest
pip3 install pytest
pytest
39 changes: 29 additions & 10 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,47 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, macOS-14]
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install cfitsio
run: ./.github/workflows/make_cfitsio.sh
shell: bash
- name: (macos) install automake and autoconf
if: ${{ startsWith(matrix.os, 'macOS') }}
run: |
brew install automake autoconf
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: install cfitsio
env:
# TODO: CFITSIO_VERSION: 4.4.0
CFITSIO_VERSION: 3.49
run: |
cd /tmp
curl "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${CFITSIO_VERSION}.tar.gz" -o cfitsio.tar.gz
tar -xf cfitsio.tar.gz
rm cfitsio.tar.gz
cd cfitsio-${CFITSIO_VERSION}
./configure --prefix=/usr/local --enable-reentrant --disable-curl
sudo make shared
sudo make install
cd ..
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo ldconfig
fi
- name: Run tests
- name: Run tests on latest stable rust
run: cargo test --release --features cfitsio-static,examples

- name: Minimum-specified Rust version works
run: |
MIN_RUST=$(grep -m1 "rust-version" Cargo.toml | sed 's|.*\"\(.*\)\"|\1|')
~/.cargo/bin/rustup install $MIN_RUST --profile minimal
cargo +${MIN_RUST} test
cargo +${MIN_RUST} test --features cfitsio-static,examples
MIN_RUST=$(grep -m1 "rust-version" Cargo.toml | sed 's|.*\"\(.*\)\"|\1|')
~/.cargo/bin/rustup install $MIN_RUST --profile minimal
cargo +${MIN_RUST} test --features cfitsio-static,examples
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

Changes in each release are listed below.

## 1.3.0 12-Apr-2024

* Added 'EDA2' and 'SHAO' as new valid `ReceiverType`s to `Rfinput` struct.
* Release and tests now include MacOS 14 Arm64 architecture binaries.

## 1.2.3 12-Mar-2024

* Removed error-inducing, unneeded `python_version` requirement from the `[build-system]` `requires` setting.

## 1.2.2 12-Mar-2024

* Explictly typed the buffer_ptr to be `signed char*` instead of the ambiguous `char*` in FFI VoltageContext read methods to fix portability issue with Arm64 platform. Fixes #67.
* Updated deprecated call when using `Duration:milliseconds`.
* Updated deprecated call when using `Duration:milliseconds`.

## 1.2.1 24-Nov-2023

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.2.3"
version = "1.3.0"
homepage = "https://github.com/MWATelescope/mwalib"
repository = "https://github.com/MWATelescope/mwalib"
readme = "README.md"
Expand Down
13 changes: 10 additions & 3 deletions src/rfinput/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ pub enum ReceiverType {
RRI,
NI,
Pseudo,
SHAO,
EDA2
}

/// Implements fmt::Display for ReceiverType
Expand All @@ -197,12 +199,15 @@ impl fmt::Display for ReceiverType {
ReceiverType::RRI => "RRI",
ReceiverType::NI => "NI",
ReceiverType::Pseudo => "Pseudo",
ReceiverType::SHAO => "SHAO",
ReceiverType::EDA2 => "EDA2",
}
)
}
}

/// Implements str::FromStr for ReceiverType enum
/// Implements str::FromStr for ReceiverType enum.
/// Non uppercase values are coverted to uppercase for comparision.
///
/// # Arguments
///
Expand All @@ -217,11 +222,13 @@ impl fmt::Display for ReceiverType {
impl std::str::FromStr for ReceiverType {
type Err = ();

fn from_str(input: &str) -> Result<ReceiverType, Self::Err> {
match input {
fn from_str(input: &str) -> Result<ReceiverType, Self::Err> {
match input.to_uppercase().as_str() {
"RRI" => Ok(ReceiverType::RRI),
"NI" => Ok(ReceiverType::NI),
"PSEUDO" => Ok(ReceiverType::Pseudo),
"SHAO" => Ok(ReceiverType::SHAO),
"EDA2" => Ok(ReceiverType::EDA2),
_ => Ok(ReceiverType::Unknown),
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/rfinput/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ fn test_string_to_receiver_type() {
assert!(String::from("RRI").parse::<ReceiverType>().unwrap() == ReceiverType::RRI);
assert!(String::from("NI").parse::<ReceiverType>().unwrap() == ReceiverType::NI);
assert!(String::from("PSEUDO").parse::<ReceiverType>().unwrap() == ReceiverType::Pseudo);
assert!(String::from("SHAO").parse::<ReceiverType>().unwrap() == ReceiverType::SHAO);
assert!(String::from("EDA2").parse::<ReceiverType>().unwrap() == ReceiverType::EDA2);

// what happens for lowercase?
assert!(String::from("rri").parse::<ReceiverType>().unwrap() == ReceiverType::RRI);

assert!(
String::from("something else")
.parse::<ReceiverType>()
Expand Down

0 comments on commit 3823218

Please sign in to comment.