Skip to content

Commit

Permalink
Merge pull request #117 from polariton/main
Browse files Browse the repository at this point in the history
filters: use importlib_resources API to avoid deprecation warning
  • Loading branch information
bmcfee committed Mar 5, 2024
2 parents 1d1a08a + 0eddd89 commit cc6eed5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-minimal.yml
Expand Up @@ -34,7 +34,7 @@ jobs:
shell: bash -l {0}
run: |
mamba install typing_extensions!=4.2 pytest
mamba install pip numpy==1.17 scipy==1.0 numba==0.53
mamba install pip numpy==1.17 scipy==1.0 numba==0.53 importlib_resources
- name: Install
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -39,7 +39,7 @@ jobs:
shell: bash -l {0}
run: |
mamba install typing_extensions!=4.2
mamba install pip numpy scipy numba pytest pytest-cov pytest-doctestplus
mamba install pip numpy scipy numba pytest pytest-cov pytest-doctestplus importlib_resources
- name: Install
shell: bash -l {0}
run: |
Expand Down
9 changes: 4 additions & 5 deletions resampy/filters.py
Expand Up @@ -46,8 +46,7 @@
'''

import numpy as np
import os
import pkg_resources
import importlib_resources
import sys

FILTER_FUNCTIONS = ['sinc_window']
Expand Down Expand Up @@ -203,10 +202,10 @@ def load_filter(filter_name):
'''

if filter_name not in FILTER_CACHE:
fname = os.path.join('data',
os.path.extsep.join([filter_name, 'npz']))
fname = importlib_resources.files("resampy") / 'data' / f'{filter_name}.npz'
with importlib_resources.as_file(fname) as f:
data = np.load(f)

data = np.load(pkg_resources.resource_filename(__name__, fname))
FILTER_CACHE[filter_name] = data['half_window'], data['precision'], data['rolloff']

return FILTER_CACHE[filter_name]
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -40,6 +40,7 @@ python_requires >= 3.6
install_requires =
numpy>=1.17
numba>=0.53
importlib_resources

[options.package_data]
resampy = data/*
Expand Down

0 comments on commit cc6eed5

Please sign in to comment.