diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index d426ab2..236d9d6 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -1,66 +1,63 @@ name: ssqueezepy CI on: - workflow_dispatch: - - pull_request: - paths: - - "ssqueezepy/*" - - "tests/*" - - ".github/workflows/*" - - ".coveragerc" - - "requirements.txt" - - "requirements-dev.txt" - - push: - branches: - - master + workflow_dispatch: + + pull_request: + paths: + - "ssqueezepy/*" + - "tests/*" + - ".github/workflows/*" + - ".coveragerc" + - "requirements.txt" + - "requirements-dev.txt" + + push: + branches: + - master jobs: - build-conda: - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" - runs-on: ubuntu-latest + build-mamba: + if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.7] + strategy: + matrix: + python-version: [3.10] - steps: - - uses: actions/checkout@v3 - - - name: Add Conda to path - run: echo $CONDA >> $GITHUB_PATH - - - name: Install Conda environment with Micromamba - uses: mamba-org/provision-with-micromamba@main - with: - cache-downloads: true - cache-env: true - environment-file: environment.yaml - extra-specs: | - python=${{ matrix.python-version }} - - - name: additional setup - shell: bash -l {0} - run: | - conda run python3 -m pip install --upgrade pip - conda run python3 -m pip install -r requirements.txt - conda run python3 -m pip install -r requirements-dev.txt + steps: + - uses: actions/checkout@v4 - - name: Set up ssqueezepy - run: conda run pip install -e . + - name: Setup Micromamba environment + uses: mamba-org/setup-micromamba@v1 + with: + micromamba-version: '1.5.8-0' + environment-file: environment.yaml + init-shell: bash + cache-environment: true + post-cleanup: 'all' + + - name: additional setup + shell: bash -l {0} + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python -m pip install -r requirements-dev.txt + + - name: Set up ssqueezepy + run: pip install -e . + + - name: Test + shell: bash -l {0} + run: > + pycodestyle --max-line-length=85 + --ignore=E221,E241,E225,E226,E402,E722,E741,E272,E266,E302,E731,E702,E201,E129,E203,E202,W503,W504 + ssqueezepy + + pytest tests/ -s --cov=ssqueezepy --cov-report=xml - - name: Test - shell: bash -l {0} - run: > - conda run pycodestyle --max-line-length=85 - --ignore=E221,E241,E225,E226,E402,E722,E741,E272,E266,E302,E731,E702,E201,E129,E203,E202,W503,W504 - ssqueezepy - - conda run pytest tests/ -s --cov=ssqueezepy --cov-report=xml - - - name: codecov upload coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - directory: ./ + - name: codecov upload coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./ diff --git a/CHANGELOG.md b/CHANGELOG.md index 876b52e..95773af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 0.6.5 + +#### FIXES + - CuPy deprecation fix (update methods to be compatible with latest CuPy) + - `imp` -> `importlib` (Python deprecation) + - Github Actions changes: use fully micromamba; actions v4; py 3.7 -> 3.10; + ### 0.6.4 #### FEATURES diff --git a/environment.yaml b/environment.yaml index 2ad449a..f325e46 100644 --- a/environment.yaml +++ b/environment.yaml @@ -9,7 +9,7 @@ dependencies: - pytest-cov - pycodestyle - pip - - python >=3.7 + - python >=3.10 - numpy - scipy - matplotlib diff --git a/ssqueezepy/__init__.py b/ssqueezepy/__init__.py index 932ffe3..ce69f5d 100644 --- a/ssqueezepy/__init__.py +++ b/ssqueezepy/__init__.py @@ -27,7 +27,7 @@ """ -__version__ = '0.6.4' +__version__ = '0.6.5' __title__ = 'ssqueezepy' __author__ = 'John Muradeli' __license__ = __doc__ diff --git a/ssqueezepy/utils/backend.py b/ssqueezepy/utils/backend.py index 0659b3d..64f1972 100644 --- a/ssqueezepy/utils/backend.py +++ b/ssqueezepy/utils/backend.py @@ -106,20 +106,14 @@ def __init__(self): self.dtype = _TensorDummy -class _Util(): - """For wrapper: `@cp._util.memoize`.""" +class CupyDummy(): + """Dummy class with dummy attributes.""" def memoize(self, *args, **kwargs): def wrap(fn): return fn return wrap -class CupyDummy(): - """Dummy class with dummy attributes.""" - def __init__(self): - self._util = _Util() - - class _Q(): """Class for accessing `numpy` or `torch` attributes according to `USE_GPU()`. """ diff --git a/ssqueezepy/utils/gpu_utils.py b/ssqueezepy/utils/gpu_utils.py index 4743703..8169275 100644 --- a/ssqueezepy/utils/gpu_utils.py +++ b/ssqueezepy/utils/gpu_utils.py @@ -14,10 +14,10 @@ def _run_on_gpu(kernel, grid, block, *args, **kwargs): stream=Stream(ptr=torch.cuda.current_stream().cuda_stream)) -@cp._util.memoize(for_each_device=True) +@cp.memoize(for_each_device=True) def load_kernel(kernel_name, code, **kwargs): code = Template(code).substitute(**kwargs) - kernel_code = cp.cuda.compile_with_cache(code) + kernel_code = cp.RawModule(code=code) return kernel_code.get_function(kernel_name) diff --git a/tests/fft_test.py b/tests/fft_test.py index 489a5e0..9c1b5d8 100644 --- a/tests/fft_test.py +++ b/tests/fft_test.py @@ -416,7 +416,7 @@ def test_buffer(): def test_ssq_stft(): - N = 256 + N = 512 tsigs = TestSignals(N=N) gpu_atol = 1e-5 @@ -578,16 +578,17 @@ def test_ssq_cwt_batched(): os.environ['SSQ_GPU'] = '1' Tx1, Wx1, *_ = ssq_cwt(x, _wavelet(dtype=dtype), **kw) - atol = 1e-12 if dtype == 'float64' else 1e-2 adiff_Tx000 = np.abs(Tx00 - Tx0).mean() adiff_Wx000 = np.abs(Wx00 - Wx0).mean() assert np.allclose(Wx00, Wx0), (dtype, adiff_Wx000) assert np.allclose(Tx00, Tx0), (dtype, adiff_Tx000) + if CAN_GPU: + gpu_atol = 1e-12 if dtype == 'float64' else 1e-2 adiff_Tx01 = np.abs(Tx0 - Tx1).mean() adiff_Wx01 = np.abs(Wx0 - Wx1).mean() - assert np.allclose(Wx0, Wx1, atol=atol), (dtype, adiff_Wx01) - assert np.allclose(Tx0, Tx1, atol=atol), (dtype, adiff_Tx01) + assert np.allclose(Wx0, Wx1, atol=gpu_atol), (dtype, adiff_Wx01) + assert np.allclose(Tx0, Tx1, atol=gpu_atol), (dtype, adiff_Tx01) # didn't investigate float32, and `allclose` threshold is pretty bad, # so check MAE @@ -617,16 +618,17 @@ def test_ssq_stft_batched(): os.environ['SSQ_GPU'] = '1' Tx1, Sx1, *_ = ssq_stft(x, **kw) - atol = 1e-12 if dtype == 'float64' else 1e-6 adiff_Tx000 = np.abs(Tx00 - Tx0).mean() adiff_Sx000 = np.abs(Sx00 - Sx0).mean() assert np.allclose(Sx00, Sx0), (dtype, adiff_Sx000) assert np.allclose(Tx00, Tx0), (dtype, adiff_Tx000) + if CAN_GPU: - adiff_Tx01 = np.abs(Tx0 - Tx1) - adiff_Sx01 = np.abs(Sx0 - Sx1) - assert np.allclose(Sx0, Sx1, atol=atol), (dtype, adiff_Sx01) - assert np.allclose(Tx0, Tx1, atol=atol), (dtype, adiff_Tx01) + gpu_atol = 1e-12 if dtype == 'float64' else 5e-6 + adiff_Tx01 = np.abs(Tx0 - Tx1).mean() + adiff_Sx01 = np.abs(Sx0 - Sx1).mean() + assert np.allclose(Sx0, Sx1, atol=gpu_atol), (dtype, adiff_Sx01) + assert np.allclose(Tx0, Tx1, atol=gpu_atol), (dtype, adiff_Tx01) def test_cwt_batched_for_loop(): diff --git a/tests/z_all_test.py b/tests/z_all_test.py index f6d1915..5d86db4 100644 --- a/tests/z_all_test.py +++ b/tests/z_all_test.py @@ -32,7 +32,7 @@ def wrap(fn): #### Ensure cached imports reloaded ########################################## from types import ModuleType -from imp import reload +from importlib import reload import ssqueezepy