Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag blimpy-docker:$(date +%s)

22 changes: 11 additions & 11 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-verison: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
Expand All @@ -34,22 +35,21 @@ jobs:
cat dependencies.txt | sudo xargs -n 1 apt install -y
- name: Install dependencies
run: |
python3 -m pip install --user --upgrade pip
python3 -m pip install --user -r requirements.txt
python3 setup.py install --user
python3 -m pip install --user -r requirements_test.txt
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install .
python -m pip install -r requirements_test.txt
- name: Download test files
run: |
cd tests
bash download_data.sh
cd ..
- name: Run coverage test
run: |
export PATH=/home/runner/.local/bin:$PATH
pytest --cov=./ --cov-report=xml
python -m pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
name: blimpy-codecov-p${{ matrix.python-version }}

7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update
Expand All @@ -10,10 +10,11 @@ RUN cat dependencies.txt | xargs -n 1 apt install --no-install-recommends -y

RUN cd tests && bash download_data.sh && cd ..

RUN python3 -m pip install --user --upgrade pip
RUN python3 -m pip install --user -r requirements.txt
RUN python3 setup.py install --user
RUN python3 -m pip install --user .
RUN python3 -m pip install --user -r requirements_test.txt
RUN python3 setup.py test
RUN python3 -m pytest

RUN rm -fr tests/test_data
RUN find . -path '*/__pycache__*' -delete
Expand Down
2 changes: 1 addition & 1 deletion MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The primary method of launching regression testing is through the use of the `py
* Also, from the same site, `blimpy` is downloaded to a local computer. The download operations can be performed in a few different ways but the simplest might be to download the zip file by clicking on the `Code` button and selecting `Download ZIP`. Once the the zip file is in a local directory, unzip it and move the blimpy directory tree to wherever is appropriate for testing. The zip file can now be discarded.
* Change directory into the `tests` directory (where this file is located) and execute `bash download_data.sh` which will perform all required regression testing initialization.
* When the previous step has completed, change directory up one level to the top of the `blimpy` directory tree.
* Execute: ```python3 setup.py install```
* Execute: ```python3 -m pip install .```
* Then, install `pytest` and `pyslalib` from pypi.org: `python3 -m pip install pytest pyslalib`.

### Regression Test Operations
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The latest release can be installed via pip directly from this repository:
python3 -m pip install -U git+https://github.com/UCBerkeleySETI/blimpy
```

Or, the latest version of the development code can be installed from the github [repo](https://github.com/UCBerkeleySETI/blimpy) and then run `python setup.py install` or `pip install .` (with sudo if required), or by using the following terminal command:
Or, the latest version of the development code can be installed from the github [repo](https://github.com/UCBerkeleySETI/blimpy) and then run `pip install .` (with sudo if required), or by using the following terminal command:

```
python3 -m pip install -U https://github.com/UCBerkeleySETI/blimpy/tarball/master
Expand Down
1 change: 1 addition & 0 deletions VERSION-HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ This file is a version history of blimpy amendments, beginning with version 2.0.
<br>
| Date | Version | Contents |
| :--: | :--: | :-- |
| 2026-10-27 | 2.1.5 | Replace deprecated pkg_resources with importlib.metadata (PR #281); fix CI. |
| 2022-11-16 | 2.1.4 | Make bl_scrunch actually work (issue #276). |
| 2022-08-02 | 2.1.3 | Write .fil files as well as .h5 files (issue #272). |
| 2022-07-22 | 2.1.2 | More container fields needed (issue #270). |
Expand Down
10 changes: 7 additions & 3 deletions blimpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
except:
print("Warning: At least one utility could not be imported!")

from pkg_resources import get_distribution, DistributionNotFound
try:
from importlib.metadata import version, PackageNotFoundError
except ImportError:
# Fallback for Python < 3.8
from importlib_metadata import version, PackageNotFoundError

try:
__version__ = get_distribution('blimpy').version
except DistributionNotFound:
__version__ = version('blimpy')
except PackageNotFoundError:
__version__ = '0.0.0 - please install via pip/setup.py'
2 changes: 1 addition & 1 deletion blimpy/dsamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Blimpy functions required:
from blimpy import Waterfall
from blimpy.io.hdf_writer import __write_to_hdf5_heavy as write_to_h5
from blimpy.io.hdf_writer import __write_to_hdf5_light as write_to_h5
from blimpy.io.fil_writer import write_to_fil


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pandas
Pillow
psutil
pyparsing==2.4.7
importlib_metadata; python_version < "3.8"
1 change: 0 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ pyslalib
pytest
pytest-cov
pytest-order
pytest-runner
setigen

6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[aliases]
test=pytest

[metadata]
description-file=README.md

[global]
no-binary = h5py

Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from setuptools import setup, find_packages

__version__ = '2.1.4'
__version__ = '2.1.5'

with open("README.md", "r") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -58,11 +58,13 @@
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Topic :: Scientific/Engineering :: Astronomy',
],
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pyslalib'],
test_suite="blimpytests",
)
15 changes: 15 additions & 0 deletions tests/test_dsamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# test_dsamp
"""

import h5py
import numpy as np
import pytest
import blimpy as bl
from tests.data import voyager_fil, voyager_h5, test_h5, test_fil
Expand All @@ -10,16 +12,29 @@
GROUP_SIZE = 3


def check_h5_is_downsampled(in_path):
""" The output .h5 data must be the sums of each group of input time samples.
"""
in_data = bl.Waterfall(in_path, max_load=None).data
n_out = in_data.shape[0] // GROUP_SIZE
expected = in_data[:n_out * GROUP_SIZE].reshape(
(n_out, GROUP_SIZE) + in_data.shape[1:]).sum(axis=1)
with h5py.File(test_h5, 'r') as h5:
assert np.allclose(h5['data'][:], expected)


def test_dsamp_fil_to_h5():
""" fil to h5 test.
"""
bl.dsamp.make_output_file(voyager_fil, test_h5, GROUP_SIZE, True)
check_h5_is_downsampled(voyager_fil)


def test_dsamp_h5_to_h5():
""" h5 to h5 test.
"""
bl.dsamp.make_output_file(voyager_h5, test_h5, GROUP_SIZE, True)
check_h5_is_downsampled(voyager_h5)


def test_dsamp_h5_to_fil():
Expand Down
23 changes: 23 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
r""" Tests for blimpy package version detection """
import subprocess
import sys

try:
from importlib.metadata import version
except ImportError:
from importlib_metadata import version

import blimpy


def test_version_matches_metadata():
assert blimpy.__version__ == version('blimpy')
assert not blimpy.__version__.startswith('0.0.0')

def test_import_has_no_pkg_resources_warning():
# Use a fresh interpreter: blimpy is already imported in this process.
result = subprocess.run(
[sys.executable, '-W', 'default', '-c', 'import blimpy'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
assert result.returncode == 0
assert 'pkg_resources' not in result.stderr
Loading