From 0ccf8ae06f818f00a43a712038607e6744c13d08 Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Tue, 7 Feb 2023 13:47:53 +0900 Subject: [PATCH] applies isort to code base, adds check in CI (#304) --- .github/workflows/lint.yml | 7 ++++++- CONTRIBUTING.rst | 9 ++++++++- docs/conf.py | 2 +- examples/adaptive_filter_stft_domain.py | 3 ++- examples/adaptive_filters.py | 3 ++- examples/beamforming_delay_and_sum.py | 5 +++-- examples/beamforming_time_domain.py | 3 ++- examples/bss_example.py | 7 ++++--- examples/bss_live.py | 7 +++---- examples/cmu_arctic_corpus.py | 3 ++- examples/datasets.py | 2 +- examples/directivities/cardioid_function.py | 5 ++--- examples/directivities/circular_mic_array.py | 6 +++--- examples/directivities/mic_array.py | 10 +++++----- .../directivities/mic_array_diff_directivities.py | 10 +++++----- examples/directivities/plot_directivity_2D.py | 6 +++--- examples/directivities/plot_directivity_3D.py | 7 +++---- examples/directivities/source_and_microphone.py | 9 +++++---- examples/doa_algorithms.py | 2 +- examples/google_speech_commands_corpus.py | 1 + examples/hmm_training.py | 4 +++- examples/noise_reduction_spectral_subtraction.py | 6 ++++-- examples/noise_reduction_subspace.py | 8 +++++--- examples/noise_reduction_wiener_filtering.py | 9 +++++---- examples/randomized_image_method.py | 8 ++++---- examples/room_complex_wall_materials.py | 1 + examples/room_from_rt60.py | 3 ++- examples/stft_block_processing.py | 7 +++++-- pyroomacoustics/adaptive/__init__.py | 2 +- pyroomacoustics/adaptive/adaptive_filter.py | 3 ++- pyroomacoustics/adaptive/lms.py | 3 ++- pyroomacoustics/adaptive/rls.py | 6 ++++-- pyroomacoustics/adaptive/tests/test_adaptive.py | 2 ++ .../adaptive/tests/test_adaptive_frequency.py | 2 ++ pyroomacoustics/bss/__init__.py | 8 ++++---- pyroomacoustics/bss/ilrma.py | 1 + pyroomacoustics/bss/sparseauxiva.py | 1 + pyroomacoustics/bss/tests/test_bss.py | 6 ++++-- pyroomacoustics/bss/tests/test_trinicon.py | 3 ++- pyroomacoustics/build_rir.pyx | 3 ++- pyroomacoustics/datasets/__init__.py | 6 +++--- pyroomacoustics/datasets/google_speech_commands.py | 6 ++++-- pyroomacoustics/datasets/tests/test_corpus_base.py | 2 +- .../datasets/tests/test_download_uncompress.py | 3 ++- pyroomacoustics/datasets/timit.py | 1 + pyroomacoustics/datasets/utils.py | 2 +- pyroomacoustics/denoise/__init__.py | 2 +- pyroomacoustics/denoise/tests/test_subspace.py | 1 + pyroomacoustics/directivities.py | 6 ++++-- pyroomacoustics/doa/__init__.py | 10 +++++----- pyroomacoustics/doa/detect_peaks.py | 1 + pyroomacoustics/doa/frida.py | 11 +++++------ pyroomacoustics/doa/grid.py | 8 ++++---- pyroomacoustics/doa/plotters.py | 4 ++-- pyroomacoustics/doa/tests/test_doa.py | 3 ++- pyroomacoustics/doa/tests/test_utils.py | 1 + pyroomacoustics/doa/tops.py | 4 ++-- pyroomacoustics/experimental/__init__.py | 8 ++++---- pyroomacoustics/experimental/localization.py | 1 + pyroomacoustics/experimental/measure_ir.py | 2 +- pyroomacoustics/experimental/point_cloud.py | 2 +- pyroomacoustics/experimental/signals.py | 1 + .../experimental/tests/test_deconvolution.py | 1 + .../experimental/tests/test_measure_rt60.py | 1 + pyroomacoustics/metrics.py | 2 +- pyroomacoustics/multirate.py | 2 +- pyroomacoustics/phase/tests/test_gl.py | 3 ++- pyroomacoustics/recognition.py | 7 ++++--- pyroomacoustics/soundsource.py | 5 +++-- pyroomacoustics/sync.py | 2 +- pyroomacoustics/tests/test_anechoic_room.py | 1 + pyroomacoustics/tests/test_angle_function.py | 5 +++-- pyroomacoustics/tests/test_autocorr.py | 6 ++++-- pyroomacoustics/tests/test_bandpass_filterbank.py | 4 ++-- pyroomacoustics/tests/test_build_rir.py | 4 +++- pyroomacoustics/tests/test_create_noisy_signal.py | 7 +++++-- pyroomacoustics/tests/test_issue_115.py | 1 + pyroomacoustics/tests/test_issue_162.py | 1 + pyroomacoustics/tests/test_issue_22.py | 1 + pyroomacoustics/tests/test_issue_236.py | 1 + pyroomacoustics/tests/test_issue_69.py | 1 + pyroomacoustics/tests/test_issue_87.py | 1 + pyroomacoustics/tests/test_materials.py | 1 - pyroomacoustics/tests/test_metrics.py | 1 + pyroomacoustics/tests/test_rake_filters.py | 1 + pyroomacoustics/tests/test_random_ism.py | 1 - pyroomacoustics/tests/test_room_add.py | 1 + pyroomacoustics/tests/test_room_is_insided.py | 1 + pyroomacoustics/tests/test_room_mix.py | 1 + pyroomacoustics/tests/test_room_plot.py | 3 ++- pyroomacoustics/tests/test_soundsource.py | 1 + pyroomacoustics/tests/test_source_directivities.py | 11 ++++++----- .../tests/test_source_directivity_flipping.py | 5 +++-- pyroomacoustics/tests/test_sync.py | 1 + pyroomacoustics/tests/test_visibility_shoebox2d.py | 1 + pyroomacoustics/tests/test_visibility_shoebox3d.py | 1 + pyroomacoustics/tests/test_visibility_uroom.py | 1 + pyroomacoustics/tests/test_volume_area.py | 1 + pyroomacoustics/tests/tests_libroom/test_ccw3p.py | 1 + .../tests/tests_libroom/test_geometry_routines.py | 1 + .../tests/tests_libroom/test_is_inside_2d_polygon.py | 1 + .../tests/tests_libroom/test_ray_energy.py | 2 ++ .../tests/tests_libroom/test_room_construct.py | 1 + .../tests/tests_libroom/test_room_walls.py | 1 + .../tests/tests_libroom/test_shoebox_simple.py | 3 ++- .../tests/tests_libroom/test_wall_construct.py | 1 + .../tests/tests_libroom/test_wall_intersection.py | 1 + .../tests/tests_libroom/test_wall_side_reflect.py | 2 ++ pyroomacoustics/transform/dft.py | 7 ++++--- pyroomacoustics/transform/stft.py | 1 + pyroomacoustics/transform/tests/test_dft.py | 3 +++ pyroomacoustics/transform/tests/test_dft_timing.py | 5 ++++- pyroomacoustics/transform/tests/test_stft.py | 3 ++- pyroomacoustics/transform/tests/test_stft_oneshot.py | 4 +++- pyroomacoustics/transform/tests/test_stft_timing.py | 6 ++++-- 115 files changed, 260 insertions(+), 149 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 71e97a3b..83cf6f89 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -29,7 +29,7 @@ jobs: python-version: 3.8 - name: Install Python dependencies - run: pip install black flake8 + run: pip install black flake8 isort - name: Run linters uses: wearerequired/lint-action@v2 @@ -37,3 +37,8 @@ jobs: black: true black_args: "--check" flake8: false + + - name: Sort imports + uses: isort/isort-action@v1.0.0 + with: + configuration: --check-only --diff --profile black diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index f559fb30..47bcf57c 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -24,9 +24,16 @@ We try to stick to `PEP8 `__ as much as possible. Variables, functions, modules and packages should be in lowercase with underscores. Class names in CamelCase. -We use `Black `__ to format the code. +We use `Black `__ to format the code and `isort `__ to sort the imports. The format will be automatically checked when doing a pull request so it is recommended to regularly run Black on the code. +Please format your code as follows prior to commiting. + +.. code-block:: shell + + pip install black isort + black . + isort --profile black . Documentation ~~~~~~~~~~~~~ diff --git a/docs/conf.py b/docs/conf.py index 9c5cfa3a..81ddbe94 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,8 +12,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os +import sys # mock modules for compilation without installing all packages MOCK_MODULES = [ diff --git a/examples/adaptive_filter_stft_domain.py b/examples/adaptive_filter_stft_domain.py index 28990923..256fe1ef 100644 --- a/examples/adaptive_filter_stft_domain.py +++ b/examples/adaptive_filter_stft_domain.py @@ -7,9 +7,10 @@ """ from __future__ import division, print_function +import matplotlib.pyplot as plt import numpy as np from scipy.signal import fftconvolve -import matplotlib.pyplot as plt + import pyroomacoustics as pra # parameters diff --git a/examples/adaptive_filters.py b/examples/adaptive_filters.py index e2d1a527..ab27296d 100644 --- a/examples/adaptive_filters.py +++ b/examples/adaptive_filters.py @@ -6,9 +6,10 @@ """ from __future__ import division, print_function +import matplotlib.pyplot as plt import numpy as np from scipy.signal import fftconvolve -import matplotlib.pyplot as plt + import pyroomacoustics as pra # parameters diff --git a/examples/beamforming_delay_and_sum.py b/examples/beamforming_delay_and_sum.py index 3642b842..4a83f1ec 100644 --- a/examples/beamforming_delay_and_sum.py +++ b/examples/beamforming_delay_and_sum.py @@ -1,10 +1,11 @@ """ This example shows how to create delay and sum beamformers """ -from __future__ import print_function, division +from __future__ import division, print_function -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import pyroomacoustics as pra # Create a 4 by 6 metres anechoic room diff --git a/examples/beamforming_time_domain.py b/examples/beamforming_time_domain.py index f6b75197..47053504 100644 --- a/examples/beamforming_time_domain.py +++ b/examples/beamforming_time_domain.py @@ -6,8 +6,9 @@ from __future__ import division, print_function import os -import numpy as np + import matplotlib.pyplot as plt +import numpy as np from scipy.io import wavfile import pyroomacoustics as pra diff --git a/examples/bss_example.py b/examples/bss_example.py index 7ed6b532..22ead9b2 100755 --- a/examples/bss_example.py +++ b/examples/bss_example.py @@ -55,10 +55,10 @@ This script requires the `mir_eval` to run, and `tkinter` and `sounddevice` packages for the GUI option. """ import time -import numpy as np -from scipy.io import wavfile +import numpy as np from mir_eval.separation import bss_eval_sources +from scipy.io import wavfile # We concatenate a few samples to make them long enough wav_files = [ @@ -292,7 +292,8 @@ def convergence_callback(Y): if args.gui: # Make a simple GUI to listen to the separated samples - from tkinter import Tk, Button, Label + from tkinter import Button, Label, Tk + import sounddevice as sd # Now comes the GUI part diff --git a/examples/bss_live.py b/examples/bss_live.py index 2cffc743..a6008c4f 100644 --- a/examples/bss_live.py +++ b/examples/bss_live.py @@ -53,18 +53,17 @@ This script requires the `sounddevice` packages to run. """ -import numpy as np - # important to avoid a crash when tkinter is called import matplotlib +import numpy as np matplotlib.use("TkAgg") -import pyroomacoustics as pra +from tkinter import Button, Label, Tk -from tkinter import Tk, Label, Button import sounddevice as sd +import pyroomacoustics as pra if __name__ == "__main__": choices = ["ilrma", "auxiva", "sparseauxiva", "fastmnmf", "fastmnmf2"] diff --git a/examples/cmu_arctic_corpus.py b/examples/cmu_arctic_corpus.py index 66703180..f7f4d027 100644 --- a/examples/cmu_arctic_corpus.py +++ b/examples/cmu_arctic_corpus.py @@ -13,10 +13,11 @@ CMU, 2003. """ -import pyroomacoustics as pra import argparse import os +import pyroomacoustics as pra + if __name__ == "__main__": parser = argparse.ArgumentParser( description="Example of using the CMUArcticCorpus wrapper" diff --git a/examples/datasets.py b/examples/datasets.py index 5b9ef316..2e747359 100644 --- a/examples/datasets.py +++ b/examples/datasets.py @@ -2,7 +2,7 @@ Example of the basic operations with ``pyroomacoustics.datasets.Dataset`` and ``pyroomacoustics.datasets.Sample`` classes """ -from pyroomacoustics.datasets import Sample, Dataset +from pyroomacoustics.datasets import Dataset, Sample # Prepare a few artificial samples samples = [ diff --git a/examples/directivities/cardioid_function.py b/examples/directivities/cardioid_function.py index 702fffb6..948acbf2 100644 --- a/examples/directivities/cardioid_function.py +++ b/examples/directivities/cardioid_function.py @@ -1,11 +1,10 @@ -import numpy as np import matplotlib.pyplot as plt +import numpy as np -from pyroomacoustics import dB, all_combinations +from pyroomacoustics import all_combinations, dB from pyroomacoustics.directivities import cardioid_func from pyroomacoustics.doa import spher2cart - azimuth = np.radians(np.linspace(start=0, stop=360, num=361, endpoint=True)) colatitude = np.radians(np.linspace(start=0, stop=180, num=180, endpoint=True)) lower_gain = -40 diff --git a/examples/directivities/circular_mic_array.py b/examples/directivities/circular_mic_array.py index 1cbf9932..d9611048 100644 --- a/examples/directivities/circular_mic_array.py +++ b/examples/directivities/circular_mic_array.py @@ -1,11 +1,11 @@ +import matplotlib.pyplot as plt + import pyroomacoustics as pra from pyroomacoustics.directivities import ( - DirectionVector, CardioidFamily, + DirectionVector, DirectivityPattern, ) -import matplotlib.pyplot as plt - three_dim = True # 2D or 3D diff --git a/examples/directivities/mic_array.py b/examples/directivities/mic_array.py index 603c4f89..e1c8dd20 100644 --- a/examples/directivities/mic_array.py +++ b/examples/directivities/mic_array.py @@ -1,13 +1,13 @@ -import pyroomacoustics as pra -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +import pyroomacoustics as pra from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) - pattern = DirectivityPattern.HYPERCARDIOID orientation = DirectionVector(azimuth=0, colatitude=0, degrees=True) diff --git a/examples/directivities/mic_array_diff_directivities.py b/examples/directivities/mic_array_diff_directivities.py index 0d17338c..adf5d057 100644 --- a/examples/directivities/mic_array_diff_directivities.py +++ b/examples/directivities/mic_array_diff_directivities.py @@ -1,13 +1,13 @@ -import pyroomacoustics as pra -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +import pyroomacoustics as pra from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) - dir_1 = CardioidFamily( orientation=DirectionVector(azimuth=180, colatitude=30, degrees=True), pattern_enum=DirectivityPattern.HYPERCARDIOID, diff --git a/examples/directivities/plot_directivity_2D.py b/examples/directivities/plot_directivity_2D.py index b6aa955d..5019ff24 100644 --- a/examples/directivities/plot_directivity_2D.py +++ b/examples/directivities/plot_directivity_2D.py @@ -1,11 +1,11 @@ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from pyroomacoustics import dB from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) orientation = DirectionVector(azimuth=0, colatitude=90, degrees=True) diff --git a/examples/directivities/plot_directivity_3D.py b/examples/directivities/plot_directivity_3D.py index fe10bbae..dc47e7b3 100644 --- a/examples/directivities/plot_directivity_3D.py +++ b/examples/directivities/plot_directivity_3D.py @@ -1,13 +1,12 @@ -import numpy as np import matplotlib.pyplot as plt +import numpy as np from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) - pattern = DirectivityPattern.HYPERCARDIOID orientation = DirectionVector(azimuth=0, colatitude=45, degrees=True) diff --git a/examples/directivities/source_and_microphone.py b/examples/directivities/source_and_microphone.py index 1df06652..0e664082 100644 --- a/examples/directivities/source_and_microphone.py +++ b/examples/directivities/source_and_microphone.py @@ -1,10 +1,11 @@ -import pyroomacoustics as pra -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +import pyroomacoustics as pra from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) three_dim = True # 2D or 3D diff --git a/examples/doa_algorithms.py b/examples/doa_algorithms.py index 07c41419..9b4e144b 100644 --- a/examples/doa_algorithms.py +++ b/examples/doa_algorithms.py @@ -42,9 +42,9 @@ """ +import matplotlib.pyplot as plt import numpy as np from scipy.signal import fftconvolve -import matplotlib.pyplot as plt import pyroomacoustics as pra from pyroomacoustics.doa import circ_dist diff --git a/examples/google_speech_commands_corpus.py b/examples/google_speech_commands_corpus.py index b1e2cd53..f10a2340 100644 --- a/examples/google_speech_commands_corpus.py +++ b/examples/google_speech_commands_corpus.py @@ -10,6 +10,7 @@ import argparse import os + import pyroomacoustics as pra if __name__ == "__main__": diff --git a/examples/hmm_training.py b/examples/hmm_training.py index ab25fbc8..4ee0792f 100644 --- a/examples/hmm_training.py +++ b/examples/hmm_training.py @@ -7,8 +7,10 @@ Then we train a second models on these examples. """ -from __future__ import print_function, division +from __future__ import division, print_function + import numpy as np + from pyroomacoustics import HMM, CircularGaussianEmission, GaussianEmission if __name__ == "__main__": diff --git a/examples/noise_reduction_spectral_subtraction.py b/examples/noise_reduction_spectral_subtraction.py index c9d08b99..2971f96b 100644 --- a/examples/noise_reduction_spectral_subtraction.py +++ b/examples/noise_reduction_spectral_subtraction.py @@ -20,11 +20,13 @@ `pyroomacoustics.denoise.apply_spectral_sub` can be used. """ +import os + +import matplotlib.pyplot as plt import numpy as np from scipy.io import wavfile -import os + import pyroomacoustics as pra -import matplotlib.pyplot as plt from pyroomacoustics.denoise import SpectralSub """ diff --git a/examples/noise_reduction_subspace.py b/examples/noise_reduction_subspace.py index 0b3d5b50..97bdfaa4 100644 --- a/examples/noise_reduction_subspace.py +++ b/examples/noise_reduction_subspace.py @@ -10,12 +10,14 @@ `pyroomacoustics.denoise.apply_subspace` can be used. """ +import os +import time + +import matplotlib.pyplot as plt import numpy as np from scipy.io import wavfile -import os + import pyroomacoustics as pra -import matplotlib.pyplot as plt -import time from pyroomacoustics.denoise import Subspace """ diff --git a/examples/noise_reduction_wiener_filtering.py b/examples/noise_reduction_wiener_filtering.py index 3fcd7639..3137e3d9 100644 --- a/examples/noise_reduction_wiener_filtering.py +++ b/examples/noise_reduction_wiener_filtering.py @@ -1,12 +1,13 @@ +import os +import time + +import matplotlib.pyplot as plt import numpy as np from scipy.io import wavfile -import os + import pyroomacoustics as pra -import matplotlib.pyplot as plt -import time from pyroomacoustics.denoise import IterativeWiener - """ Test and algorithm parameters """ diff --git a/examples/randomized_image_method.py b/examples/randomized_image_method.py index 19d716ca..3207d0a7 100644 --- a/examples/randomized_image_method.py +++ b/examples/randomized_image_method.py @@ -6,13 +6,13 @@ image method to remove sweeping echoes in RIRs simulated with ISM. """ -import numpy as np -import pyroomacoustics as pra import matplotlib.pyplot as plt -from pyroomacoustics.transform import stft -from pyroomacoustics import metrics as met +import numpy as np from mpl_toolkits.mplot3d import Axes3D +import pyroomacoustics as pra +from pyroomacoustics import metrics as met +from pyroomacoustics.transform import stft # create an example with sweeping echo - from Enzo's paper room_size = [4, 4, 4] diff --git a/examples/room_complex_wall_materials.py b/examples/room_complex_wall_materials.py index 2225517e..fc9a2359 100644 --- a/examples/room_complex_wall_materials.py +++ b/examples/room_complex_wall_materials.py @@ -6,6 +6,7 @@ """ import matplotlib.pyplot as plt import numpy as np + import pyroomacoustics as pra # Define the materials array diff --git a/examples/room_from_rt60.py b/examples/room_from_rt60.py index 8cc291db..b97681b8 100644 --- a/examples/room_from_rt60.py +++ b/examples/room_from_rt60.py @@ -8,9 +8,10 @@ import matplotlib.pyplot as plt import numpy as np -import pyroomacoustics as pra from scipy.io import wavfile +import pyroomacoustics as pra + methods = ["ism", "hybrid"] if __name__ == "__main__": diff --git a/examples/stft_block_processing.py b/examples/stft_block_processing.py index c5b554bd..843656f4 100644 --- a/examples/stft_block_processing.py +++ b/examples/stft_block_processing.py @@ -14,11 +14,14 @@ """ from __future__ import division, print_function + +import os + +import matplotlib.pyplot as plt import numpy as np from scipy.io import wavfile -import matplotlib.pyplot as plt + import pyroomacoustics as pra -import os # filter to apply h_len = 99 diff --git a/pyroomacoustics/adaptive/__init__.py b/pyroomacoustics/adaptive/__init__.py index 381839b1..ac74b4de 100644 --- a/pyroomacoustics/adaptive/__init__.py +++ b/pyroomacoustics/adaptive/__init__.py @@ -103,11 +103,11 @@ """ from .adaptive_filter import * +from .data_structures import * from .lms import * from .rls import * from .subband_lms import * from .util import * -from .data_structures import * # Create this dictionary as a shortcut to different algorithms algorithms = { diff --git a/pyroomacoustics/adaptive/adaptive_filter.py b/pyroomacoustics/adaptive/adaptive_filter.py index 6034d233..8bfb307d 100644 --- a/pyroomacoustics/adaptive/adaptive_filter.py +++ b/pyroomacoustics/adaptive/adaptive_filter.py @@ -1,6 +1,7 @@ from __future__ import division, print_function -import scipy.linalg as la + import numpy as np +import scipy.linalg as la class AdaptiveFilter: diff --git a/pyroomacoustics/adaptive/lms.py b/pyroomacoustics/adaptive/lms.py index 646b9ff1..a36446b2 100644 --- a/pyroomacoustics/adaptive/lms.py +++ b/pyroomacoustics/adaptive/lms.py @@ -5,7 +5,8 @@ Implementations of adaptive filters from the LMS class. These algorithms have a low complexity and reliable behavior with a somewhat slower convergence. """ -from __future__ import division, print_function, absolute_import +from __future__ import absolute_import, division, print_function + import numpy as np import scipy.linalg as la diff --git a/pyroomacoustics/adaptive/rls.py b/pyroomacoustics/adaptive/rls.py index dc48c82e..bf5549b7 100644 --- a/pyroomacoustics/adaptive/rls.py +++ b/pyroomacoustics/adaptive/rls.py @@ -6,10 +6,12 @@ typically have a higher computational complexity, but a faster convergence. """ -from __future__ import division, print_function, absolute_import +from __future__ import absolute_import, division, print_function + import numpy as np -from .data_structures import Buffer, Powers + from .adaptive_filter import AdaptiveFilter +from .data_structures import Buffer, Powers from .util import hankel_stride_trick diff --git a/pyroomacoustics/adaptive/tests/test_adaptive.py b/pyroomacoustics/adaptive/tests/test_adaptive.py index 4bf3102a..24157ba7 100644 --- a/pyroomacoustics/adaptive/tests/test_adaptive.py +++ b/pyroomacoustics/adaptive/tests/test_adaptive.py @@ -1,8 +1,10 @@ from __future__ import division, print_function from unittest import TestCase + import numpy as np from scipy.signal import fftconvolve + import pyroomacoustics as pra # fix RNG for a deterministic result diff --git a/pyroomacoustics/adaptive/tests/test_adaptive_frequency.py b/pyroomacoustics/adaptive/tests/test_adaptive_frequency.py index d298dc23..7da09a54 100644 --- a/pyroomacoustics/adaptive/tests/test_adaptive_frequency.py +++ b/pyroomacoustics/adaptive/tests/test_adaptive_frequency.py @@ -1,8 +1,10 @@ from __future__ import division, print_function from unittest import TestCase + import numpy as np from scipy.signal import fftconvolve + import pyroomacoustics as pra # fix RNG for a deterministic result diff --git a/pyroomacoustics/bss/__init__.py b/pyroomacoustics/bss/__init__.py index 03e9eb3f..3549e178 100644 --- a/pyroomacoustics/bss/__init__.py +++ b/pyroomacoustics/bss/__init__.py @@ -57,10 +57,10 @@ """ -from .trinicon import trinicon from .auxiva import auxiva -from .ilrma import ilrma -from .sparseauxiva import sparseauxiva +from .common import projection_back, sparir from .fastmnmf import fastmnmf from .fastmnmf2 import fastmnmf2 -from .common import projection_back, sparir +from .ilrma import ilrma +from .sparseauxiva import sparseauxiva +from .trinicon import trinicon diff --git a/pyroomacoustics/bss/ilrma.py b/pyroomacoustics/bss/ilrma.py index 04798c6b..1bd27840 100644 --- a/pyroomacoustics/bss/ilrma.py +++ b/pyroomacoustics/bss/ilrma.py @@ -24,6 +24,7 @@ Blind Source Separation using Independent Low-Rank Matrix Analysis (ILRMA). """ import numpy as np + from .common import projection_back diff --git a/pyroomacoustics/bss/sparseauxiva.py b/pyroomacoustics/bss/sparseauxiva.py index 5d843712..37d5fdf0 100644 --- a/pyroomacoustics/bss/sparseauxiva.py +++ b/pyroomacoustics/bss/sparseauxiva.py @@ -25,6 +25,7 @@ # not, see . import numpy as np + from .common import projection_back, sparir diff --git a/pyroomacoustics/bss/tests/test_bss.py b/pyroomacoustics/bss/tests/test_bss.py index cd2c28d7..24e0aee5 100644 --- a/pyroomacoustics/bss/tests/test_bss.py +++ b/pyroomacoustics/bss/tests/test_bss.py @@ -1,7 +1,9 @@ +import unittest + import numpy as np -import pyroomacoustics as pra from scipy.io import wavfile -import unittest + +import pyroomacoustics as pra np.random.seed(0) diff --git a/pyroomacoustics/bss/tests/test_trinicon.py b/pyroomacoustics/bss/tests/test_trinicon.py index 49440f0c..f023ff3d 100644 --- a/pyroomacoustics/bss/tests/test_trinicon.py +++ b/pyroomacoustics/bss/tests/test_trinicon.py @@ -1,7 +1,8 @@ import numpy as np -import pyroomacoustics as pra from scipy.io import wavfile +import pyroomacoustics as pra + # We use several sound samples for each source to have a long enough length wav_files = [ [ diff --git a/pyroomacoustics/build_rir.pyx b/pyroomacoustics/build_rir.pyx index 63413fa5..5c0941d7 100644 --- a/pyroomacoustics/build_rir.pyx +++ b/pyroomacoustics/build_rir.pyx @@ -1,9 +1,10 @@ # cython: infer_types=True import numpy as np + cimport cython +from libc.math cimport ceil, floor -from libc.math cimport floor, ceil @cython.boundscheck(False) @cython.wraparound(False) diff --git a/pyroomacoustics/datasets/__init__.py b/pyroomacoustics/datasets/__init__.py index 03e67fc5..a8cea886 100644 --- a/pyroomacoustics/datasets/__init__.py +++ b/pyroomacoustics/datasets/__init__.py @@ -137,7 +137,7 @@ """ -from .base import Meta, Sample, AudioSample, Dataset -from .timit import Word, Sentence, TimitCorpus +from .base import AudioSample, Dataset, Meta, Sample from .cmu_arctic import CMUArcticCorpus, CMUArcticSentence, cmu_arctic_speakers -from .google_speech_commands import GoogleSpeechCommands, GoogleSample +from .google_speech_commands import GoogleSample, GoogleSpeechCommands +from .timit import Sentence, TimitCorpus, Word diff --git a/pyroomacoustics/datasets/google_speech_commands.py b/pyroomacoustics/datasets/google_speech_commands.py index ddc71ab2..01153ef5 100644 --- a/pyroomacoustics/datasets/google_speech_commands.py +++ b/pyroomacoustics/datasets/google_speech_commands.py @@ -19,7 +19,9 @@ https://www.tensorflow.org/versions/master/tutorials/audio_recognition """ -import os, glob +import glob +import os + import numpy as np from scipy.io import wavfile @@ -30,8 +32,8 @@ except: have_sounddevice = False +from .base import AudioSample, Dataset, Meta from .utils import download_uncompress -from .base import Meta, AudioSample, Dataset url = "http://download.tensorflow.org/data/speech_commands_v0.01.tar.gz" diff --git a/pyroomacoustics/datasets/tests/test_corpus_base.py b/pyroomacoustics/datasets/tests/test_corpus_base.py index f954f66a..4d356b24 100644 --- a/pyroomacoustics/datasets/tests/test_corpus_base.py +++ b/pyroomacoustics/datasets/tests/test_corpus_base.py @@ -2,7 +2,7 @@ Example of the basic operations with ``pyroomacoustics.datasets.Dataset`` and ``pyroomacoustics.datasets.Sample`` classes """ -from pyroomacoustics.datasets import Sample, Dataset +from pyroomacoustics.datasets import Dataset, Sample def test_dataset(): diff --git a/pyroomacoustics/datasets/tests/test_download_uncompress.py b/pyroomacoustics/datasets/tests/test_download_uncompress.py index 339b5ee8..9d683d0b 100644 --- a/pyroomacoustics/datasets/tests/test_download_uncompress.py +++ b/pyroomacoustics/datasets/tests/test_download_uncompress.py @@ -1,7 +1,8 @@ import shutil -from pyroomacoustics.datasets.utils import download_uncompress import ssl +from pyroomacoustics.datasets.utils import download_uncompress + test_url = "https://github.com/LCAV/pyroomacoustics/archive/master.tar.gz" extracted_name = "pyroomacoustics-master" diff --git a/pyroomacoustics/datasets/timit.py b/pyroomacoustics/datasets/timit.py index 0a501fd9..2e8dc7d7 100644 --- a/pyroomacoustics/datasets/timit.py +++ b/pyroomacoustics/datasets/timit.py @@ -18,6 +18,7 @@ import os import numpy as np + from pyroomacoustics.transform import stft try: diff --git a/pyroomacoustics/datasets/utils.py b/pyroomacoustics/datasets/utils.py index b865ddca..d106cb3c 100644 --- a/pyroomacoustics/datasets/utils.py +++ b/pyroomacoustics/datasets/utils.py @@ -22,9 +22,9 @@ # You should have received a copy of the MIT License along with this program. If # not, see . +import bz2 import os import tarfile -import bz2 try: from urllib.request import urlopen diff --git a/pyroomacoustics/denoise/__init__.py b/pyroomacoustics/denoise/__init__.py index 842bdbd2..789d6cc0 100644 --- a/pyroomacoustics/denoise/__init__.py +++ b/pyroomacoustics/denoise/__init__.py @@ -24,6 +24,6 @@ """ +from .iterative_wiener import * from .spectral_subtraction import * from .subspace import * -from .iterative_wiener import * diff --git a/pyroomacoustics/denoise/tests/test_subspace.py b/pyroomacoustics/denoise/tests/test_subspace.py index 2dd658a7..77bb4057 100644 --- a/pyroomacoustics/denoise/tests/test_subspace.py +++ b/pyroomacoustics/denoise/tests/test_subspace.py @@ -3,6 +3,7 @@ from unittest import TestCase import numpy as np + from pyroomacoustics.denoise import Subspace tol = 1e-7 diff --git a/pyroomacoustics/directivities.py b/pyroomacoustics/directivities.py index 61289cad..d900bd47 100644 --- a/pyroomacoustics/directivities.py +++ b/pyroomacoustics/directivities.py @@ -1,8 +1,10 @@ import abc -import numpy as np from enum import Enum + +import numpy as np + from pyroomacoustics.doa import spher2cart -from pyroomacoustics.utilities import requires_matplotlib, all_combinations +from pyroomacoustics.utilities import all_combinations, requires_matplotlib class DirectivityPattern(Enum): diff --git a/pyroomacoustics/doa/__init__.py b/pyroomacoustics/doa/__init__.py index 2769a82c..057d52c6 100644 --- a/pyroomacoustics/doa/__init__.py +++ b/pyroomacoustics/doa/__init__.py @@ -108,16 +108,16 @@ """ +from .cssm import * from .doa import * -from .srp import * +from .frida import * +from .grid import * from .music import * from .normmusic import * -from .cssm import * -from .waves import * +from .srp import * from .tops import * -from .frida import * -from .grid import * from .utils import * +from .waves import * # Create this dictionary as a shortcut to different algorithms algorithms = { diff --git a/pyroomacoustics/doa/detect_peaks.py b/pyroomacoustics/doa/detect_peaks.py index d32d23b2..ed3d1220 100644 --- a/pyroomacoustics/doa/detect_peaks.py +++ b/pyroomacoustics/doa/detect_peaks.py @@ -7,6 +7,7 @@ """ from __future__ import division, print_function + import numpy as np __author__ = "Marcos Duarte, https://github.com/demotu/BMC" diff --git a/pyroomacoustics/doa/frida.py b/pyroomacoustics/doa/frida.py index cb6752a8..6e51a0e6 100644 --- a/pyroomacoustics/doa/frida.py +++ b/pyroomacoustics/doa/frida.py @@ -1,17 +1,16 @@ from __future__ import division, print_function +import numpy as np from scipy import linalg as la -# import numpy as np - -from .doa import * +from .doa import DOA from .tools_fri_doa_plane import ( - pt_src_recon_multiband, - extract_off_diag, cov_mtx_est, - polar2cart, + extract_off_diag, make_G, make_GtG_and_inv, + polar2cart, + pt_src_recon_multiband, ) diff --git a/pyroomacoustics/doa/grid.py b/pyroomacoustics/doa/grid.py index 07e1e691..6cf965ce 100644 --- a/pyroomacoustics/doa/grid.py +++ b/pyroomacoustics/doa/grid.py @@ -1,13 +1,13 @@ """ Routines to perform grid search on the sphere """ -from __future__ import division, print_function, absolute_import +from __future__ import absolute_import, division, print_function + +from abc import ABCMeta, abstractmethod import numpy as np import scipy.spatial as sp # import ConvexHull, SphericalVoronoi -from abc import ABCMeta, abstractmethod - from .detect_peaks import detect_peaks from .utils import great_circ_dist @@ -368,10 +368,10 @@ def plot_old(self, plot_points=False, mark_peaks=0): try: import matplotlib.colors as colors + import matplotlib.pyplot as plt # from mpl_toolkits.mplot3d import Axes3D import mpl_toolkits.mplot3d as a3 - import matplotlib.pyplot as plt except ImportError: import warnings diff --git a/pyroomacoustics/doa/plotters.py b/pyroomacoustics/doa/plotters.py index 38f9430c..8b1846bc 100644 --- a/pyroomacoustics/doa/plotters.py +++ b/pyroomacoustics/doa/plotters.py @@ -240,9 +240,9 @@ def sph_plot_diracs_plotly( """ try: - from plotly.offline import plot - import plotly.graph_objs as go import plotly + import plotly.graph_objs as go + from plotly.offline import plot except ImportError: import warnings diff --git a/pyroomacoustics/doa/tests/test_doa.py b/pyroomacoustics/doa/tests/test_doa.py index 85800040..dfd9903b 100644 --- a/pyroomacoustics/doa/tests/test_doa.py +++ b/pyroomacoustics/doa/tests/test_doa.py @@ -5,9 +5,10 @@ import unittest import numpy as np -import pyroomacoustics as pra from scipy.signal import fftconvolve +import pyroomacoustics as pra + # fix the RNG seed for repeatability np.random.seed(0) diff --git a/pyroomacoustics/doa/tests/test_utils.py b/pyroomacoustics/doa/tests/test_utils.py index 9dde23c7..856211b8 100644 --- a/pyroomacoustics/doa/tests/test_utils.py +++ b/pyroomacoustics/doa/tests/test_utils.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/doa/tops.py b/pyroomacoustics/doa/tops.py index a1ce30d7..7a9eb0c4 100644 --- a/pyroomacoustics/doa/tops.py +++ b/pyroomacoustics/doa/tops.py @@ -2,10 +2,10 @@ # Date: July 15, 2016 import numpy as np -from .music import MUSIC +from scipy import linalg from scipy.linalg import svdvals -from scipy import linalg +from .music import MUSIC class TOPS(MUSIC): diff --git a/pyroomacoustics/experimental/__init__.py b/pyroomacoustics/experimental/__init__.py index 0d0e2ab0..74b76607 100644 --- a/pyroomacoustics/experimental/__init__.py +++ b/pyroomacoustics/experimental/__init__.py @@ -16,11 +16,11 @@ "rt60", ] +from .deconvolution import deconvolve, wiener_deconvolve +from .delay_calibration import DelayCalibration +from .localization import edm_line_search, tdoa, tdoa_loc from .measure_ir import measure_ir from .physics import calculate_speed_of_sound from .point_cloud import PointCloud -from .delay_calibration import DelayCalibration -from .deconvolution import deconvolve, wiener_deconvolve -from .localization import tdoa, tdoa_loc, edm_line_search -from .signals import window, exponential_sweep, linear_sweep from .rt60 import measure_rt60 +from .signals import exponential_sweep, linear_sweep, window diff --git a/pyroomacoustics/experimental/localization.py b/pyroomacoustics/experimental/localization.py index 73cd63b9..169d58e5 100644 --- a/pyroomacoustics/experimental/localization.py +++ b/pyroomacoustics/experimental/localization.py @@ -2,6 +2,7 @@ import numpy as np from scipy import linalg as la + from .point_cloud import PointCloud try: diff --git a/pyroomacoustics/experimental/measure_ir.py b/pyroomacoustics/experimental/measure_ir.py index d1488004..b598a832 100644 --- a/pyroomacoustics/experimental/measure_ir.py +++ b/pyroomacoustics/experimental/measure_ir.py @@ -7,8 +7,8 @@ except: sounddevice_available = False -from .signals import exponential_sweep, linear_sweep from .deconvolution import wiener_deconvolve +from .signals import exponential_sweep, linear_sweep _sweep_types = { "exponential": exponential_sweep, diff --git a/pyroomacoustics/experimental/point_cloud.py b/pyroomacoustics/experimental/point_cloud.py index ae77daeb..ec25e03f 100644 --- a/pyroomacoustics/experimental/point_cloud.py +++ b/pyroomacoustics/experimental/point_cloud.py @@ -337,8 +337,8 @@ def doa(self, receiver, source): def plot(self, axes=None, show_labels=True, **kwargs): try: - from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt + from mpl_toolkits.mplot3d import Axes3D except ImportError: import warnings diff --git a/pyroomacoustics/experimental/signals.py b/pyroomacoustics/experimental/signals.py index 8eb691e6..e6659af0 100644 --- a/pyroomacoustics/experimental/signals.py +++ b/pyroomacoustics/experimental/signals.py @@ -2,6 +2,7 @@ A few test signals like sweeps and stuff. """ from __future__ import division, print_function + import numpy as np diff --git a/pyroomacoustics/experimental/tests/test_deconvolution.py b/pyroomacoustics/experimental/tests/test_deconvolution.py index 276475d9..c6bed504 100644 --- a/pyroomacoustics/experimental/tests/test_deconvolution.py +++ b/pyroomacoustics/experimental/tests/test_deconvolution.py @@ -1,4 +1,5 @@ from unittest import TestCase + import numpy as np from scipy.signal import fftconvolve diff --git a/pyroomacoustics/experimental/tests/test_measure_rt60.py b/pyroomacoustics/experimental/tests/test_measure_rt60.py index 648d898d..a85faa1e 100644 --- a/pyroomacoustics/experimental/tests/test_measure_rt60.py +++ b/pyroomacoustics/experimental/tests/test_measure_rt60.py @@ -21,6 +21,7 @@ Test code for RT60 measurement routine """ import numpy as np + import pyroomacoustics as pra eps = 1e-15 diff --git a/pyroomacoustics/metrics.py b/pyroomacoustics/metrics.py index 04965894..bd4ef6d5 100644 --- a/pyroomacoustics/metrics.py +++ b/pyroomacoustics/metrics.py @@ -2,9 +2,9 @@ import platform import numpy as np +from scipy.signal import hann from scipy.stats import binom as _binom from scipy.stats import norm as _norm -from scipy.signal import hann from .transform import stft diff --git a/pyroomacoustics/multirate.py b/pyroomacoustics/multirate.py index 62470a7d..4edb237b 100644 --- a/pyroomacoustics/multirate.py +++ b/pyroomacoustics/multirate.py @@ -27,7 +27,7 @@ def frac_delay(delta, N, w_max=0.9, C=4): n = np.arange(N) try: - from cvxopt import solvers, matrix + from cvxopt import matrix, solvers except: raise ValueError( "To use the frac_delay function, the cvxopt module is necessary." diff --git a/pyroomacoustics/phase/tests/test_gl.py b/pyroomacoustics/phase/tests/test_gl.py index 3766c690..91d77699 100644 --- a/pyroomacoustics/phase/tests/test_gl.py +++ b/pyroomacoustics/phase/tests/test_gl.py @@ -9,9 +9,10 @@ import unittest import numpy as np -import pyroomacoustics as pra from scipy.io import wavfile +import pyroomacoustics as pra + test_tol = 1e-2 filename = "examples/input_samples/cmu_arctic_us_axb_a0004.wav" diff --git a/pyroomacoustics/recognition.py b/pyroomacoustics/recognition.py index c391d899..d2b68e0e 100644 --- a/pyroomacoustics/recognition.py +++ b/pyroomacoustics/recognition.py @@ -1,10 +1,11 @@ from __future__ import division, print_function -import numpy as np import os -from scipy.stats import multivariate_normal -import sys import struct +import sys + +import numpy as np +from scipy.stats import multivariate_normal try: import sounddevice as sd diff --git a/pyroomacoustics/soundsource.py b/pyroomacoustics/soundsource.py index 89e94c2a..b301a8c4 100644 --- a/pyroomacoustics/soundsource.py +++ b/pyroomacoustics/soundsource.py @@ -4,8 +4,9 @@ from __future__ import division, print_function import numpy as np -from .parameters import constants + from .directivities import Directivity +from .parameters import constants class SoundSource(object): @@ -348,7 +349,7 @@ def build_rir_matrix(mics, sources, Lg, Fs, epsilon=5e-3, unit_damping=False): """ from .beamforming import distance - from .utilities import low_pass_dirac, convmtx + from .utilities import convmtx, low_pass_dirac for s in sources: if s.damping.shape[0] > 1: diff --git a/pyroomacoustics/sync.py b/pyroomacoustics/sync.py index ad36eee9..61ce3bd7 100644 --- a/pyroomacoustics/sync.py +++ b/pyroomacoustics/sync.py @@ -105,7 +105,7 @@ def time_align(ref, deg, L=4096): """ # estimate delay of signal - from numpy import zeros, minimum + from numpy import minimum, zeros delay = delay_estimation(ref, deg, L) diff --git a/pyroomacoustics/tests/test_anechoic_room.py b/pyroomacoustics/tests/test_anechoic_room.py index 63edbd45..431f6be5 100644 --- a/pyroomacoustics/tests/test_anechoic_room.py +++ b/pyroomacoustics/tests/test_anechoic_room.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_angle_function.py b/pyroomacoustics/tests/test_angle_function.py index 8b7d679c..95b1b403 100644 --- a/pyroomacoustics/tests/test_angle_function.py +++ b/pyroomacoustics/tests/test_angle_function.py @@ -1,7 +1,8 @@ -import numpy as np -from pyroomacoustics import angle_function from unittest import TestCase +import numpy as np + +from pyroomacoustics import angle_function pi = np.pi diff --git a/pyroomacoustics/tests/test_autocorr.py b/pyroomacoustics/tests/test_autocorr.py index 6e8221ee..bfffd16b 100644 --- a/pyroomacoustics/tests/test_autocorr.py +++ b/pyroomacoustics/tests/test_autocorr.py @@ -1,7 +1,9 @@ +import time +from unittest import TestCase + import numpy as np + from pyroomacoustics import autocorr -from unittest import TestCase -import time N = 256 n_iter = 100 diff --git a/pyroomacoustics/tests/test_bandpass_filterbank.py b/pyroomacoustics/tests/test_bandpass_filterbank.py index 71b0d14e..07c9c94d 100644 --- a/pyroomacoustics/tests/test_bandpass_filterbank.py +++ b/pyroomacoustics/tests/test_bandpass_filterbank.py @@ -1,11 +1,11 @@ """ This tests the construction of a bank of octave filters """ -import pyroomacoustics as pra - import numpy as np from scipy.signal import sosfreqz +import pyroomacoustics as pra + tol = 1.0 # decibel diff --git a/pyroomacoustics/tests/test_build_rir.py b/pyroomacoustics/tests/test_build_rir.py index 117c467b..496651be 100644 --- a/pyroomacoustics/tests/test_build_rir.py +++ b/pyroomacoustics/tests/test_build_rir.py @@ -1,7 +1,9 @@ from __future__ import division, print_function -import pyroomacoustics as pra + import numpy as np +import pyroomacoustics as pra + try: from pyroomacoustics import build_rir diff --git a/pyroomacoustics/tests/test_create_noisy_signal.py b/pyroomacoustics/tests/test_create_noisy_signal.py index 51b623a3..62da9972 100644 --- a/pyroomacoustics/tests/test_create_noisy_signal.py +++ b/pyroomacoustics/tests/test_create_noisy_signal.py @@ -1,10 +1,13 @@ from __future__ import division, print_function + +import os from unittest import TestCase + import numpy as np -import os -from pyroomacoustics import create_noisy_signal, rms, normalize from scipy.io import wavfile +from pyroomacoustics import create_noisy_signal, normalize, rms + tol = 1e-5 signal_fp = os.path.join( diff --git a/pyroomacoustics/tests/test_issue_115.py b/pyroomacoustics/tests/test_issue_115.py index 9f50db62..a2accfb2 100644 --- a/pyroomacoustics/tests/test_issue_115.py +++ b/pyroomacoustics/tests/test_issue_115.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_issue_162.py b/pyroomacoustics/tests/test_issue_162.py index 13be9f10..66e6479d 100644 --- a/pyroomacoustics/tests/test_issue_162.py +++ b/pyroomacoustics/tests/test_issue_162.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_issue_22.py b/pyroomacoustics/tests/test_issue_22.py index 1da75d23..76f3cb66 100644 --- a/pyroomacoustics/tests/test_issue_22.py +++ b/pyroomacoustics/tests/test_issue_22.py @@ -15,6 +15,7 @@ fallback version), then nothing is done. """ import numpy as np + import pyroomacoustics diff --git a/pyroomacoustics/tests/test_issue_236.py b/pyroomacoustics/tests/test_issue_236.py index 3f57a185..271d277b 100644 --- a/pyroomacoustics/tests/test_issue_236.py +++ b/pyroomacoustics/tests/test_issue_236.py @@ -2,6 +2,7 @@ import numpy import numpy as np + import pyroomacoustics as pra warnings.filterwarnings(action="ignore", category=UserWarning) diff --git a/pyroomacoustics/tests/test_issue_69.py b/pyroomacoustics/tests/test_issue_69.py index 83af8ca0..a14471be 100644 --- a/pyroomacoustics/tests/test_issue_69.py +++ b/pyroomacoustics/tests/test_issue_69.py @@ -1,6 +1,7 @@ import unittest import numpy as np + import pyroomacoustics as pra room_dim = [15, 14, 16] diff --git a/pyroomacoustics/tests/test_issue_87.py b/pyroomacoustics/tests/test_issue_87.py index 4a1f7e9b..7553843c 100644 --- a/pyroomacoustics/tests/test_issue_87.py +++ b/pyroomacoustics/tests/test_issue_87.py @@ -1,6 +1,7 @@ import unittest import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_materials.py b/pyroomacoustics/tests/test_materials.py index e6157fe4..141d1d3d 100644 --- a/pyroomacoustics/tests/test_materials.py +++ b/pyroomacoustics/tests/test_materials.py @@ -4,7 +4,6 @@ """ import pyroomacoustics as pra - scat_test = { "coeffs": [0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.3], "center_freqs": [125, 250, 500, 1000, 2000, 4000, 8000], diff --git a/pyroomacoustics/tests/test_metrics.py b/pyroomacoustics/tests/test_metrics.py index d54ce172..b0450264 100644 --- a/pyroomacoustics/tests/test_metrics.py +++ b/pyroomacoustics/tests/test_metrics.py @@ -1,5 +1,6 @@ import numpy as np from scipy.stats import norm as _norm + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_rake_filters.py b/pyroomacoustics/tests/test_rake_filters.py index f187500b..e7a93994 100644 --- a/pyroomacoustics/tests/test_rake_filters.py +++ b/pyroomacoustics/tests/test_rake_filters.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra room = pra.ShoeBox([4, 6], fs=16000, max_order=1) diff --git a/pyroomacoustics/tests/test_random_ism.py b/pyroomacoustics/tests/test_random_ism.py index 26980c5c..bcb809a4 100644 --- a/pyroomacoustics/tests/test_random_ism.py +++ b/pyroomacoustics/tests/test_random_ism.py @@ -8,7 +8,6 @@ import pyroomacoustics as pra from pyroomacoustics import metrics as met - # create an example with sweeping echo - from Enzo's paper room_size = [4, 4, 4] source_loc = [1, 2, 2] diff --git a/pyroomacoustics/tests/test_room_add.py b/pyroomacoustics/tests/test_room_add.py index f6a87d46..9826196c 100644 --- a/pyroomacoustics/tests/test_room_add.py +++ b/pyroomacoustics/tests/test_room_add.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra sig = np.arange(10) diff --git a/pyroomacoustics/tests/test_room_is_insided.py b/pyroomacoustics/tests/test_room_is_insided.py index b4d8cac2..8629af29 100644 --- a/pyroomacoustics/tests/test_room_is_insided.py +++ b/pyroomacoustics/tests/test_room_is_insided.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_room_mix.py b/pyroomacoustics/tests/test_room_mix.py index ee10a6a1..336ebb3c 100644 --- a/pyroomacoustics/tests/test_room_mix.py +++ b/pyroomacoustics/tests/test_room_mix.py @@ -4,6 +4,7 @@ import unittest import numpy as np + import pyroomacoustics as pra e_abs = 1.0 - (1.0 - 0.25) ** 2 diff --git a/pyroomacoustics/tests/test_room_plot.py b/pyroomacoustics/tests/test_room_plot.py index b01a8c74..1456601e 100644 --- a/pyroomacoustics/tests/test_room_plot.py +++ b/pyroomacoustics/tests/test_room_plot.py @@ -1,6 +1,7 @@ -import pyroomacoustics as pra import matplotlib +import pyroomacoustics as pra + matplotlib.use("Agg") diff --git a/pyroomacoustics/tests/test_soundsource.py b/pyroomacoustics/tests/test_soundsource.py index 9df72cbf..c8c713d1 100644 --- a/pyroomacoustics/tests/test_soundsource.py +++ b/pyroomacoustics/tests/test_soundsource.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_source_directivities.py b/pyroomacoustics/tests/test_source_directivities.py index 7b1e68e1..f7176e24 100644 --- a/pyroomacoustics/tests/test_source_directivities.py +++ b/pyroomacoustics/tests/test_source_directivities.py @@ -1,12 +1,13 @@ -import pyroomacoustics as pra +from unittest import TestCase + import numpy as np + +import pyroomacoustics as pra from pyroomacoustics.directivities import ( - DirectivityPattern, - DirectionVector, CardioidFamily, + DirectionVector, + DirectivityPattern, ) -from unittest import TestCase - # create room room = pra.ShoeBox( diff --git a/pyroomacoustics/tests/test_source_directivity_flipping.py b/pyroomacoustics/tests/test_source_directivity_flipping.py index 05c48cf5..46bcfc76 100644 --- a/pyroomacoustics/tests/test_source_directivity_flipping.py +++ b/pyroomacoustics/tests/test_source_directivity_flipping.py @@ -1,7 +1,8 @@ -import pyroomacoustics as pra -import numpy as np from unittest import TestCase +import numpy as np + +import pyroomacoustics as pra import pyroomacoustics.directivities diff --git a/pyroomacoustics/tests/test_sync.py b/pyroomacoustics/tests/test_sync.py index a95da9e1..5ccfce62 100644 --- a/pyroomacoustics/tests/test_sync.py +++ b/pyroomacoustics/tests/test_sync.py @@ -1,5 +1,6 @@ import numpy as np from scipy.signal import fftconvolve + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/test_visibility_shoebox2d.py b/pyroomacoustics/tests/test_visibility_shoebox2d.py index cc691484..9f279ba5 100644 --- a/pyroomacoustics/tests/test_visibility_shoebox2d.py +++ b/pyroomacoustics/tests/test_visibility_shoebox2d.py @@ -5,6 +5,7 @@ import unittest import numpy as np + import pyroomacoustics as pra fs = 8000 diff --git a/pyroomacoustics/tests/test_visibility_shoebox3d.py b/pyroomacoustics/tests/test_visibility_shoebox3d.py index 3107d4fc..7732eff6 100644 --- a/pyroomacoustics/tests/test_visibility_shoebox3d.py +++ b/pyroomacoustics/tests/test_visibility_shoebox3d.py @@ -5,6 +5,7 @@ import unittest import numpy as np + import pyroomacoustics as pra fs = 8000 diff --git a/pyroomacoustics/tests/test_visibility_uroom.py b/pyroomacoustics/tests/test_visibility_uroom.py index 58efb585..25fd0585 100644 --- a/pyroomacoustics/tests/test_visibility_uroom.py +++ b/pyroomacoustics/tests/test_visibility_uroom.py @@ -5,6 +5,7 @@ from unittest import TestCase import numpy as np + import pyroomacoustics as pra fs = 8000 diff --git a/pyroomacoustics/tests/test_volume_area.py b/pyroomacoustics/tests/test_volume_area.py index 09c6418e..7309b46d 100644 --- a/pyroomacoustics/tests/test_volume_area.py +++ b/pyroomacoustics/tests/test_volume_area.py @@ -1,4 +1,5 @@ import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/tests_libroom/test_ccw3p.py b/pyroomacoustics/tests/tests_libroom/test_ccw3p.py index dda2557d..b4c492e5 100644 --- a/pyroomacoustics/tests/tests_libroom/test_ccw3p.py +++ b/pyroomacoustics/tests/tests_libroom/test_ccw3p.py @@ -23,6 +23,7 @@ # not, see . import numpy as np + import pyroomacoustics as pra cases = { diff --git a/pyroomacoustics/tests/tests_libroom/test_geometry_routines.py b/pyroomacoustics/tests/tests_libroom/test_geometry_routines.py index ab9a3abd..713464cf 100644 --- a/pyroomacoustics/tests/tests_libroom/test_geometry_routines.py +++ b/pyroomacoustics/tests/tests_libroom/test_geometry_routines.py @@ -24,6 +24,7 @@ from __future__ import division import unittest + import numpy as np import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/tests_libroom/test_is_inside_2d_polygon.py b/pyroomacoustics/tests/tests_libroom/test_is_inside_2d_polygon.py index 98c72033..8841eb15 100644 --- a/pyroomacoustics/tests/tests_libroom/test_is_inside_2d_polygon.py +++ b/pyroomacoustics/tests/tests_libroom/test_is_inside_2d_polygon.py @@ -24,6 +24,7 @@ from __future__ import division import numpy as np + import pyroomacoustics as pra polygons = [ diff --git a/pyroomacoustics/tests/tests_libroom/test_ray_energy.py b/pyroomacoustics/tests/tests_libroom/test_ray_energy.py index ac3efaeb..440b7815 100644 --- a/pyroomacoustics/tests/tests_libroom/test_ray_energy.py +++ b/pyroomacoustics/tests/tests_libroom/test_ray_energy.py @@ -24,7 +24,9 @@ from __future__ import division import unittest + import numpy as np + import pyroomacoustics as pra diff --git a/pyroomacoustics/tests/tests_libroom/test_room_construct.py b/pyroomacoustics/tests/tests_libroom/test_room_construct.py index 386c79a6..9e661342 100644 --- a/pyroomacoustics/tests/tests_libroom/test_room_construct.py +++ b/pyroomacoustics/tests/tests_libroom/test_room_construct.py @@ -24,6 +24,7 @@ from __future__ import division import numpy as np + import pyroomacoustics as pra wall_corners = [ diff --git a/pyroomacoustics/tests/tests_libroom/test_room_walls.py b/pyroomacoustics/tests/tests_libroom/test_room_walls.py index 9252adee..8e9708f9 100644 --- a/pyroomacoustics/tests/tests_libroom/test_room_walls.py +++ b/pyroomacoustics/tests/tests_libroom/test_room_walls.py @@ -26,6 +26,7 @@ import unittest import numpy as np + import pyroomacoustics as pra c0 = np.array( diff --git a/pyroomacoustics/tests/tests_libroom/test_shoebox_simple.py b/pyroomacoustics/tests/tests_libroom/test_shoebox_simple.py index 10b18be6..e0110d05 100644 --- a/pyroomacoustics/tests/tests_libroom/test_shoebox_simple.py +++ b/pyroomacoustics/tests/tests_libroom/test_shoebox_simple.py @@ -8,9 +8,10 @@ https://github.com/LCAV/pyroomacoustics/issues/293 """ import numpy as np -import pyroomacoustics as pra import pytest +import pyroomacoustics as pra + def test_issu293_segfault_2d(): np.random.seed(0) diff --git a/pyroomacoustics/tests/tests_libroom/test_wall_construct.py b/pyroomacoustics/tests/tests_libroom/test_wall_construct.py index 5191327b..3e35868b 100644 --- a/pyroomacoustics/tests/tests_libroom/test_wall_construct.py +++ b/pyroomacoustics/tests/tests_libroom/test_wall_construct.py @@ -24,6 +24,7 @@ from __future__ import division import numpy as np + import pyroomacoustics as pra eps = 1e-6 diff --git a/pyroomacoustics/tests/tests_libroom/test_wall_intersection.py b/pyroomacoustics/tests/tests_libroom/test_wall_intersection.py index 31ffc796..ebd31be6 100644 --- a/pyroomacoustics/tests/tests_libroom/test_wall_intersection.py +++ b/pyroomacoustics/tests/tests_libroom/test_wall_intersection.py @@ -24,6 +24,7 @@ from __future__ import division import numpy as np + import pyroomacoustics as pra eps = 1e-6 diff --git a/pyroomacoustics/tests/tests_libroom/test_wall_side_reflect.py b/pyroomacoustics/tests/tests_libroom/test_wall_side_reflect.py index 180c1055..1478376f 100644 --- a/pyroomacoustics/tests/tests_libroom/test_wall_side_reflect.py +++ b/pyroomacoustics/tests/tests_libroom/test_wall_side_reflect.py @@ -24,7 +24,9 @@ from __future__ import division import unittest + import numpy as np + import pyroomacoustics as pra eps = 1e-6 diff --git a/pyroomacoustics/transform/dft.py b/pyroomacoustics/transform/dft.py index 8d0690b1..54b5c38c 100644 --- a/pyroomacoustics/transform/dft.py +++ b/pyroomacoustics/transform/dft.py @@ -16,10 +16,11 @@ https://github.com/IntelPython/mkl_fft """ -import numpy as np -from numpy.fft import rfft, irfft import warnings +import numpy as np +from numpy.fft import irfft, rfft + try: import pyfftw @@ -156,7 +157,7 @@ def __init__( if transform == "fftw": if pyfftw_available: - from pyfftw import empty_aligned, FFTW + from pyfftw import FFTW, empty_aligned self.transform = transform # allocate input (real) and output for pyfftw diff --git a/pyroomacoustics/transform/stft.py b/pyroomacoustics/transform/stft.py index 27f6e71a..aedaa2fe 100644 --- a/pyroomacoustics/transform/stft.py +++ b/pyroomacoustics/transform/stft.py @@ -27,6 +27,7 @@ import numpy as np from numpy.lib.stride_tricks import as_strided as _as_strided + from .dft import DFT diff --git a/pyroomacoustics/transform/tests/test_dft.py b/pyroomacoustics/transform/tests/test_dft.py index 8511245b..4bca514c 100644 --- a/pyroomacoustics/transform/tests/test_dft.py +++ b/pyroomacoustics/transform/tests/test_dft.py @@ -1,6 +1,9 @@ from __future__ import division, print_function + from unittest import TestCase + import numpy as np + import pyroomacoustics as pra tol = -80 # dB diff --git a/pyroomacoustics/transform/tests/test_dft_timing.py b/pyroomacoustics/transform/tests/test_dft_timing.py index 8da539cd..4c2523fd 100644 --- a/pyroomacoustics/transform/tests/test_dft_timing.py +++ b/pyroomacoustics/transform/tests/test_dft_timing.py @@ -1,7 +1,10 @@ from __future__ import division, print_function + +import time + import numpy as np + import pyroomacoustics as pra -import time try: import pyfftw diff --git a/pyroomacoustics/transform/tests/test_stft.py b/pyroomacoustics/transform/tests/test_stft.py index f164f670..a44f28f5 100644 --- a/pyroomacoustics/transform/tests/test_stft.py +++ b/pyroomacoustics/transform/tests/test_stft.py @@ -3,9 +3,10 @@ from unittest import TestCase import numpy as np +from scipy.signal import fftconvolve + import pyroomacoustics as pra from pyroomacoustics.transform import STFT -from scipy.signal import fftconvolve """ We create a signal, a simple filter and compute their convolution. diff --git a/pyroomacoustics/transform/tests/test_stft_oneshot.py b/pyroomacoustics/transform/tests/test_stft_oneshot.py index 071f5f53..6471e10e 100644 --- a/pyroomacoustics/transform/tests/test_stft_oneshot.py +++ b/pyroomacoustics/transform/tests/test_stft_oneshot.py @@ -1,10 +1,12 @@ from __future__ import division, print_function + from unittest import TestCase + import numpy as np + import pyroomacoustics as pra from pyroomacoustics.transform import stft - # test parameters tol = -100 # dB np.random.seed(0) diff --git a/pyroomacoustics/transform/tests/test_stft_timing.py b/pyroomacoustics/transform/tests/test_stft_timing.py index 7957d256..c1e74d53 100644 --- a/pyroomacoustics/transform/tests/test_stft_timing.py +++ b/pyroomacoustics/transform/tests/test_stft_timing.py @@ -1,10 +1,12 @@ from __future__ import division, print_function +import time +import warnings + import numpy as np + import pyroomacoustics as pra from pyroomacoustics.transform import STFT -import time -import warnings # test signal np.random.seed(0)