Repository: MWATelescope/mwalib (language: python)

Issue:
SHAO and EDA2 receiver type support for rf_input struct
New Metafits values are "SHAO" and "EDA2"


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 3406027..0a8ece8 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -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
@@ -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: |
diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml
index f6fec18..303444e 100644
--- a/.github/workflows/releases.yml
+++ b/.github/workflows/releases.yml
@@ -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: |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad33d4a..d993553 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
 
 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.
@@ -9,7 +14,7 @@ Changes in each release are listed below.
 ## 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
 
diff --git a/Cargo.toml b/Cargo.toml
index 8e80792..602d728 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs
index 2bafccb..28f9821 100644
--- a/src/rfinput/mod.rs
+++ b/src/rfinput/mod.rs
@@ -173,6 +173,8 @@ pub enum ReceiverType {
     RRI,
     NI,
     Pseudo,
+    SHAO,
+    EDA2
 }
 
 /// Implements fmt::Display for ReceiverType
@@ -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
 ///
@@ -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),
         }
     }


Test patch:
diff --git a/.github/workflows/run_python_tests.yml b/.github/workflows/run_python_tests.yml
index 41d10d4..da85021 100644
--- a/.github/workflows/run_python_tests.yml
+++ b/.github/workflows/run_python_tests.yml
@@ -19,16 +19,22 @@ 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:
@@ -36,6 +42,25 @@ jobs:
           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:
@@ -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
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index 0ff0c53..5f8bf00 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -19,14 +19,15 @@ 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
@@ -34,13 +35,31 @@ jobs:
           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
\ No newline at end of file
+        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
\ No newline at end of file
diff --git a/src/rfinput/test.rs b/src/rfinput/test.rs
index 2921dec..2a2d6dd 100644
--- a/src/rfinput/test.rs
+++ b/src/rfinput/test.rs
@@ -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>()