Skip to content

Commit

Permalink
Merge pull request #56 from ssalonen/fix-42
Browse files Browse the repository at this point in the history
Fix 42
  • Loading branch information
hifiberry authored Mar 2, 2023
2 parents 5318d5e + a5ebc1f commit 2f1c897
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Python package

on: [push]
on: [push, pull_request]

jobs:
build:
Expand All @@ -9,14 +9,15 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
sudo apt install gcc libasound-dev
Expand All @@ -29,7 +30,7 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# pip install pytest
# pytest
- name: Test with pytest
run: |
pip install pytest
pytest
1 change: 1 addition & 0 deletions hifiberrydsp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = "0.20"
_called_from_test = False
4 changes: 4 additions & 0 deletions hifiberrydsp/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def pytest_configure(config):
import hifiberrydsp
hifiberrydsp._called_from_test = True
25 changes: 15 additions & 10 deletions hifiberrydsp/hardware/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@
SOFTWARE.
'''
import logging


def init_spi():
import spidev
spi = spidev.SpiDev()
spi.open(0, 0)
spi.bits_per_word = 8
spi.max_speed_hz = 1000000
spi.mode = 0
logging.debug("spi initialized %s", spi)
import hifiberrydsp

def init_spi():
if not hifiberrydsp._called_from_test:
# only open the device when not running tests
import spidev
spi = spidev.SpiDev()
spi.open(0, 0)
spi.bits_per_word = 8
spi.max_speed_hz = 1000000
spi.mode = 0
logging.debug("spi initialized %s", spi)
else:
spi = None
logging.debug("spi not initialized since running tests")
return spi


Expand Down
4 changes: 2 additions & 2 deletions hifiberrydsp/parser/rew.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def readfilters(filename, fs=48000):
fc = float(parts[5])
gain = float(parts[8])
q = float(parts[11])
logging.info("Filter EQ fc=%s, q=%s, gaion=%s, fs=%s",
logging.info("Filter EQ fc=%s, q=%s, gain=%s, fs=%s",
fc, q, gain, fs)
filters.append(
Biquad.peaking_eq(fc, q, gain, fs))
Expand Down Expand Up @@ -109,7 +109,7 @@ def readfilters(filename, fs=48000):
parts[4] == "Fc" and parts[6] == "Hz":
fc = float(parts[5])
q = 0.707
logging.info("Filter NO fc=%s", fc, db)
logging.info("Filter NO fc=%s q=%s", fc, q)
filters.append(
Biquad.notch(fc, q, fs))

Expand Down

0 comments on commit 2f1c897

Please sign in to comment.