diff --git a/clarity/evaluator/msbg/smearing.py b/clarity/evaluator/msbg/smearing.py index 29c59500d..a3f72b287 100644 --- a/clarity/evaluator/msbg/smearing.py +++ b/clarity/evaluator/msbg/smearing.py @@ -124,10 +124,11 @@ def smear3(f_smear: ndarray, inbuffer: ndarray) -> ndarray: winwave = np.zeros(FFT_SIZE) winwave[0:FRAME_SIZE] = window * inwave.flatten() spectrum = np.fft.fft(winwave, FFT_SIZE) - power = spectrum[0:nyquist] * np.conj(spectrum[0:nyquist]) - mag = np.sqrt(power) + + mag = np.abs(spectrum[0:nyquist]) phasor = spectrum[0:nyquist] / (mag + (mag == 0)) - smeared = np.dot(f_smear, power) + + smeared = np.dot(f_smear, (mag**2).astype(complex)) spectrum[0:nyquist] = np.sqrt(smeared) * phasor spectrum[nyquist] = 0 spectrum[(nyquist + 1) : FFT_SIZE] = np.conj(spectrum[nyquist - 1 : 0 : -1]) diff --git a/pyproject.toml b/pyproject.toml index 06ea661a4..1f9fa9d24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,104 +1,92 @@ [build-system] -requires = [ - "setuptools >= 45", - "setuptools_scm[toml]>=6.2", - "wheel", - ] +requires = ["setuptools >= 45", "setuptools_scm[toml]>=6.2", "wheel"] build-backend = "setuptools.build_meta" [project] name = "pyclarity" description = "Tools for the Clarity Challenge" readme = "README.md" -license = {text = "MIT"} +license = { text = "MIT" } dynamic = ["version"] authors = [ - {name = "The PyClarity Team", email = "claritychallengecontact@gmail.com"}, + { name = "The PyClarity Team", email = "claritychallengecontact@gmail.com" }, ] classifiers = [ - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Natural Language :: English", -] -keywords = [ - "hearing", - "signal processing", - "clarity challenge" -] + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Natural Language :: English", +] +keywords = ["hearing", "signal processing", "clarity challenge"] requires-python = ">=3.8" dependencies = [ - "audioread>=2.1.9", - "gdown", - "hydra-core>=1.1.1", - "hydra-submitit-launcher>=1.1.6", - "importlib-metadata", - "librosa>=0.8.1", - "matplotlib", - "numba>=0.57.0rc", - "numpy>=1.21.6,<1.25.0", - "omegaconf>=2.1.1", - "pandas>=1.3.5", - "pyflac", - "pyloudnorm>=0.1.0", - "pystoi", - "pytorch-lightning", - "resampy", - "scikit-learn>=1.0.2", - "scipy>=1.7.3", - "SoundFile>=0.10.3.post1", - "soxr", - "torch>=2", - "torchaudio", - "tqdm>=4.62.3", - "typing_extensions", + "audioread>=2.1.9", + "gdown", + "hydra-core>=1.1.1", + "hydra-submitit-launcher>=1.1.6", + "importlib-metadata", + "librosa>=0.8.1", + "matplotlib", + "numba>=0.57.0rc", + "numpy>=1.21.6", + "omegaconf>=2.1.1", + "pandas>=1.3.5", + "pyflac", + "pyloudnorm>=0.1.0", + "pystoi", + "pytorch-lightning", + "resampy", + "scikit-learn>=1.0.2", + "scipy>=1.7.3", + "SoundFile>=0.10.3.post1", + "soxr", + "torch>=2", + "torchaudio", + "tqdm>=4.62.3", + "typing_extensions", ] [project.optional-dependencies] tests = [ - "coverage", - "isort", - "flake8", - "flake8-print", - "Flake8-pyproject", - "mypy", - "pre-commit", - "py", - "py-cpuinfo", - "pytest", - "pytest-cov", - "pytest-mock", - "pytest-mpl", - "pytest-regtest", - "pytest-skip-slow", - "pytest-xdist", - "yamllint", -] -docs =[ - "sphinx", - "myst_parser", - "pydata_sphinx_theme", - "sphinx_markdown_tables", - "sphinx_rtd_theme", - "sphinxcontrib-mermaid", - "sphinxcontrib-napoleon", + "coverage", + "isort", + "flake8", + "flake8-print", + "Flake8-pyproject", + "mypy", + "pre-commit", + "py", + "py-cpuinfo", + "pytest", + "pytest-cov", + "pytest-mock", + "pytest-mpl", + "pytest-regtest", + "pytest-skip-slow", + "pytest-xdist", + "yamllint", +] +docs = [ + "sphinx", + "myst_parser", + "pydata_sphinx_theme", + "sphinx_markdown_tables", + "sphinx_rtd_theme", + "sphinxcontrib-mermaid", + "sphinxcontrib-napoleon", ] dev = [ - "black", - "pre-commit", - "pycodestyle", - "pylint", - "pylint-pytest", - "yamllint", -] -pypi =[ - "build", - "wheel", - "setuptools_scm[toml]" -] + "black", + "pre-commit", + "pycodestyle", + "pylint", + "pylint-pytest", + "yamllint", +] +pypi = ["build", "wheel", "setuptools_scm[toml]"] [project.urls] Source = "https://github.com/claritychallenge/clarity" @@ -118,17 +106,8 @@ exclude = ["tests*"] namespaces = false [tool.setuptools.package-data] -clarity = [ - "*.json", - "*.mat", - "*.yaml" -] -recipes = [ - "*.csv", - "*.json", - "*.mat", - "*.yaml" -] +clarity = ["*.json", "*.mat", "*.yaml"] +recipes = ["*.csv", "*.json", "*.mat", "*.yaml"] [tool.setuptools_scm] @@ -140,21 +119,12 @@ git_describe_command = "git describe --tags" [tool.pytest.ini_options] minversion = "7.0" addopts = "--cov clarity" -testpaths = [ - "tests", -] -filterwarnings = [ - "ignore::UserWarning" -] +testpaths = ["tests"] +filterwarnings = ["ignore::UserWarning"] [tool.coverage.run] source = ["clarity"] -omit = [ - "*conftest.py", - "*tests*", - "**/__init__*", - "clarity/_version.py", -] +omit = ["*conftest.py", "*tests*", "**/__init__*", "clarity/_version.py"] [tool.black] line-length = 88 @@ -171,23 +141,11 @@ exclude = ''' ''' [flake8] -ignore =[ - "E203", - "E501", - "W503", -] +ignore = ["E203", "E501", "W503"] # docstring-convention = "" max-line-length = 88 max-complexity = 18 -select = [ - "B", - "C", - "E", - "F", - "W", - "T4", - "B9" -] +select = ["B", "C", "E", "F", "W", "T4", "B9"] [tool.ruff] exclude = [ @@ -221,7 +179,4 @@ fixable = ["A", "B", "C", "D", "E", "F", "R", "S", "W", "U"] [tool.mypy] ignore_missing_imports = true -exclude = [ - "docs/*", - "build/*" -] +exclude = ["docs/*", "build/*"]