Skip to content

Commit

Permalink
Format with new Black version 23.1.0 (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakufaku authored Feb 6, 2023
1 parent 7f015ce commit b73182a
Show file tree
Hide file tree
Showing 104 changed files with 90 additions and 698 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __getattr__(cls, name):

numpydoc_show_class_members = False


# Custom function to define some 'noisy' class members to skip
def skip_member(app, what, name, obj, skip, options):
exclusions = (
Expand Down
6 changes: 0 additions & 6 deletions docs/make_materials_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,17 @@ def format_freq(f):


def print_section(title, data, headers, file):

print(title, file=file)
print("-" * len(title), file=file)
print(file=file)

for subtitle, materials in data.items():

print(subtitle, file=file)
print("^" * len(subtitle), file=file)
print(file=file)

table = []
for keyword, p in materials.items():

# fill the table
row = [keyword, p["description"]]
for c in p["coeffs"]:
Expand All @@ -57,7 +54,6 @@ def print_section(title, data, headers, file):


if __name__ == "__main__":

with open(datafile, "r") as f:
data = json.load(f)

Expand All @@ -66,7 +62,6 @@ def print_section(title, data, headers, file):
]

with open(docfile, "w") as f:

print("Materials Database", file=f)
print("==================", file=f)
print(file=f)
Expand All @@ -77,7 +72,6 @@ def print_section(title, data, headers, file):
}

for key, sectitle in sections.items():

print_section(
title=sectitle,
data=data[key],
Expand Down
8 changes: 1 addition & 7 deletions examples/adaptive_filter_stft_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@
num_blocks = 0
X_concat = np.zeros((num_bands, n_samples // hop), dtype=np.complex64)
while n_samples - n > hop:

stft_in.analysis(
x[
n : n + hop,
]
)
stft_in.analysis(x[n : n + hop,])
X_concat[:, num_blocks] = stft_in.X

n += hop
Expand All @@ -73,7 +68,6 @@
error_per_band = np.zeros((num_bands, num_blocks), dtype=np.complex64)
time_idx = 0
for n in range(num_blocks):

# update filter with new samples
adaptive_filters.update(X_concat[:, n], D_concat[:, n])
error_per_band[:, n] = np.linalg.norm(adaptive_filters.W.conj() - W, axis=0)
Expand Down
3 changes: 0 additions & 3 deletions examples/bss_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
]

if __name__ == "__main__":

choices = ["ilrma", "auxiva", "sparseauxiva", "fastmnmf", "fastmnmf2"]

import argparse
Expand Down Expand Up @@ -153,7 +152,6 @@
# Record each source separately
separate_recordings = []
for source, signal in zip(room.sources, signals):

source.signal[:] = signal

room.simulate()
Expand Down Expand Up @@ -293,7 +291,6 @@ def convergence_callback(Y):
)

if args.gui:

# Make a simple GUI to listen to the separated samples
from tkinter import Tk, Button, Label
import sounddevice as sd
Expand Down
1 change: 0 additions & 1 deletion examples/bss_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@


if __name__ == "__main__":

choices = ["ilrma", "auxiva", "sparseauxiva", "fastmnmf", "fastmnmf2"]

import argparse
Expand Down
1 change: 0 additions & 1 deletion examples/cmu_arctic_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Example of using the CMUArcticCorpus wrapper"
)
Expand Down
1 change: 0 additions & 1 deletion examples/directivities/plot_directivity_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
fig = plt.figure()
ax = plt.subplot(111, projection="polar")
for pattern in DirectivityPattern:

dir_obj = CardioidFamily(orientation=orientation, pattern_enum=pattern)
resp = dir_obj.get_response(azimuth=angles, magnitude=True, degrees=False)
resp_db = dB(np.array(resp))
Expand Down
1 change: 0 additions & 1 deletion examples/doa_anechoic_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
methods = ["MUSIC", "FRIDA", "WAVES", "TOPS", "CSSM", "SRP", "NormMUSIC"]

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Estimates the direction of arrival of a sound source."
)
Expand Down
1 change: 0 additions & 1 deletion examples/google_speech_commands_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pyroomacoustics as pra

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Example of using the GoogleSpeechCommands wrapper"
)
Expand Down
1 change: 0 additions & 1 deletion examples/hmm_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pyroomacoustics import HMM, CircularGaussianEmission, GaussianEmission

if __name__ == "__main__":

K = 4 # number of states
O = 6 # dimension of the emission vector
model = "left-right" # transition matrix model
Expand Down
1 change: 0 additions & 1 deletion examples/noise_reduction_spectral_subtraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
processed_audio = np.zeros(signal.shape)
n = 0
while noisy_signal.shape[0] - n >= hop:

# SCNR in frequency domain
stft.analysis(noisy_signal[n : (n + hop)])
gain_filt = scnr.compute_gain_filter(stft.X)
Expand Down
5 changes: 1 addition & 4 deletions examples/noise_reduction_subspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@
start_time = time.time()
hop = frame_len // 2
while noisy_signal.shape[0] - n >= hop:

processed_audio[
n : n + hop,
] = scnr.apply(noisy_signal[n : n + hop])
processed_audio[n : n + hop,] = scnr.apply(noisy_signal[n : n + hop])

# update step
n += hop
Expand Down
1 change: 0 additions & 1 deletion examples/noise_reduction_wiener_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
processed_audio = np.zeros(noisy_signal.shape)
n = 0
while noisy_signal.shape[0] - n >= hop:

# to frequency domain, 50% overlap
stft.analysis(noisy_signal[n : (n + hop)])

Expand Down
2 changes: 0 additions & 2 deletions examples/randomized_image_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@

print("Sweeping echo measure for ISM is :")
for n in range(M):

if n == 0:
S = stft.analysis(
room.rir[n][0], fft_size, fft_hop, win=analysis_window, zp_back=fft_zp
Expand Down Expand Up @@ -133,7 +132,6 @@

print("Sweeping echo measure for randomized ISM is:")
for n in range(M):

if n == 0:
S = stft.analysis(
room.rir[n][0], fft_size, fft_hop, win=analysis_window, zp_back=fft_zp
Expand Down
2 changes: 0 additions & 2 deletions examples/raytracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@


def get_rir(size, reverb):

# We construct a non-shoebox room
pol = size_opts[size]["mult"] * np.array([[0, 0], [0, 4], [3, 2], [3, 0]]).T
mat = pra.Material(reverb_opts[reverb]["e_abs"])
Expand Down Expand Up @@ -66,7 +65,6 @@ def get_rir(size, reverb):


if __name__ == "__main__":

parser = argparse.ArgumentParser(
description=(
"Demonstrates the use of ray tracing for rooms of "
Expand Down
1 change: 0 additions & 1 deletion examples/room_from_rt60.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
methods = ["ism", "hybrid"]

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Simulates and adds reverberation to a dry sound sample. Saves it into `./examples/samples`."
)
Expand Down
1 change: 0 additions & 1 deletion examples/room_from_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
default_stl_path = Path(__file__).parent / "data/INRIA_MUSIS.stl"

if __name__ == "__main__":

parser = argparse.ArgumentParser(description="Basic room from STL file example")
parser.add_argument(
"--file", type=str, default=default_stl_path, help="Path to STL file"
Expand Down
2 changes: 0 additions & 2 deletions examples/room_shoebox_3d_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ def chrono(f, *args, **kwargs):


if __name__ == "__main__":

rirs = {}

for name, config in params.items():

print("Simulate: ", name)

shoebox = make_room(config)
Expand Down
1 change: 0 additions & 1 deletion examples/stft_block_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
# process the signals while full blocks are available
n = 0
while audio.shape[0] - n > hop:

# go to frequency domain
stft.analysis(audio[n : n + hop])

Expand Down
2 changes: 0 additions & 2 deletions pyroomacoustics/acoustics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def bandpass_filterbank(bands, fs=1.0, order=8, output="sos"):
nyquist = fs / 2.0

for band in bands:

# remove bands above nyquist frequency
if band[0] >= nyquist:
raise ValueError("Bands should be below Nyquist frequency")
Expand Down Expand Up @@ -161,7 +160,6 @@ class OctaveBandsFactory(object):
"""

def __init__(self, base_frequency=125.0, fs=16000, n_fft=512):

self.base_freq = base_frequency
self.fs = fs
self.n_fft = n_fft
Expand Down
2 changes: 0 additions & 2 deletions pyroomacoustics/adaptive/adaptive_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class AdaptiveFilter:
"""

def __init__(self, length):

# filter length
self.length = length

Expand Down Expand Up @@ -54,5 +53,4 @@ def update(self, x_n, d_n):
self.d = d_n

def name(self):

return self.__class__.__name__
5 changes: 0 additions & 5 deletions pyroomacoustics/adaptive/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Buffer:
"""

def __init__(self, length=20, dtype=np.float64):

self.buf = np.zeros(length, dtype=dtype)
self.len = length
self.head = self.len
Expand Down Expand Up @@ -71,7 +70,6 @@ def __getitem__(self, r):
return ptr[r]

def __repr__(self):

if self.head == self.len:
return "[]"
else:
Expand Down Expand Up @@ -103,12 +101,10 @@ class Powers:
"""

def __init__(self, a, length=20, dtype=np.float64):

self.a = dtype(a)
self.pwr = self.a ** np.arange(length)

def __getitem__(self, r):

# find maximum power requested
if isinstance(r, int):
high = r + 1
Expand Down Expand Up @@ -148,7 +144,6 @@ class CoinFlipper:
"""

def __init__(self, p, length=10000):

self.p = p
self.length = length
self.buffer = np.random.random(length) < p
Expand Down
3 changes: 0 additions & 3 deletions pyroomacoustics/adaptive/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class NLMS(AdaptiveFilter):
"""

def __init__(self, length, mu=0.5):

self.mu = mu
AdaptiveFilter.__init__(self, length)

Expand Down Expand Up @@ -65,7 +64,6 @@ class BlockLMS(NLMS):
"""

def __init__(self, length, mu=0.01, L=1, nlms=False):

self.nlms = nlms

# sketching parameters
Expand Down Expand Up @@ -103,7 +101,6 @@ def update(self, x_n, d_n):

# Block update
if self.n % self.L == 0:

# block-update parameters
X = la.hankel(self.x[: self.L], r=self.x[self.L - 1 :])

Expand Down
4 changes: 1 addition & 3 deletions pyroomacoustics/adaptive/rls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .adaptive_filter import AdaptiveFilter
from .util import hankel_stride_trick


# First the classic RLS (for real numbered signals)
class RLS(AdaptiveFilter):
"""
Expand All @@ -32,7 +33,6 @@ class RLS(AdaptiveFilter):
"""

def __init__(self, length, lmbd=0.999, delta=10, dtype=np.float32):

self.lmbd = lmbd
self.lmbd_inv = 1 / lmbd
self.delta = delta
Expand Down Expand Up @@ -129,7 +129,6 @@ class BlockRLS(RLS):
"""

def __init__(self, length, lmbd=0.999, delta=10, dtype=np.float32, L=None):

# block size
if L is None:
self.block = length
Expand Down Expand Up @@ -178,7 +177,6 @@ def update(self, x_n, d_n):

# Block update
if self.n % self.block == 0:

x_vec = self.x.top(self.block + self.length - 1)
d_vec = self.d.top(self.block)

Expand Down
2 changes: 0 additions & 2 deletions pyroomacoustics/adaptive/subband_lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class SubbandLMS:
"""

def __init__(self, num_taps, num_bands, mu=0.5, nlms=True):

self.num_taps = num_taps
self.num_bands = num_bands
self.mu = mu
Expand All @@ -53,7 +52,6 @@ def __init__(self, num_taps, num_bands, mu=0.5, nlms=True):
self.reset()

def reset(self):

# filter bank
self.W = np.zeros((self.num_taps, self.num_bands), dtype=np.complex64)

Expand Down
1 change: 1 addition & 0 deletions pyroomacoustics/adaptive/tests/test_adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# convolve with the unknown filter
d_clean = fftconvolve(x, w)[:n_samples]


# a function to the adaptive filter on all the samples
def run_filter(algorithm, x, d):
for i in range(x.shape[0]):
Expand Down
Loading

0 comments on commit b73182a

Please sign in to comment.