From 134eaf9c8ffcd1a47b85216b57cc58e2d8a223a4 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Tue, 13 Mar 2018 10:30:53 +0100 Subject: [PATCH 1/5] minor fixes --- thunderfish/Auxiliary.py | 2 +- thunderfish/time_analysis.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/thunderfish/Auxiliary.py b/thunderfish/Auxiliary.py index caf4c5eb..e68f3a98 100644 --- a/thunderfish/Auxiliary.py +++ b/thunderfish/Auxiliary.py @@ -4,7 +4,7 @@ import os import numpy as np import wave -from scipy.signal import butter, filtfil +from scipy.signal import butter, filtfilt try: import matplotlib.pyplot as plt except ImportError: diff --git a/thunderfish/time_analysis.py b/thunderfish/time_analysis.py index ab2e8753..496ad4e4 100644 --- a/thunderfish/time_analysis.py +++ b/thunderfish/time_analysis.py @@ -1830,7 +1830,7 @@ def main(file_path, hobo_path, show_fish_plot=False, show_combined_fishes=False, old_colors = False for enu, folder in enumerate(sorted(folders)): - print folder + print(folder) # load data dat_file = False fishes = False @@ -2128,4 +2128,4 @@ def main(file_path, hobo_path, show_fish_plot=False, show_combined_fishes=False, parser.add_argument('hobo_path', nargs='?', default='', type=str, help='folder containing the hobo datalogger files') args = parser.parse_args() - main(args.file_path, args.hobo_path) \ No newline at end of file + main(args.file_path, args.hobo_path) From c4dd130219c32c79e474363e968cfa9f5f2baff7 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Fri, 26 Oct 2018 17:05:21 +0200 Subject: [PATCH 2/5] [testPeakdetect] cast to int when using for indexing --- tests/test_peakdetection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_peakdetection.py b/tests/test_peakdetection.py index 77696b67..ae534f2d 100644 --- a/tests/test_peakdetection.py +++ b/tests/test_peakdetection.py @@ -40,7 +40,7 @@ def test_detect_peaks(): assert_raises(ValueError, pd.detect_peaks, data, -1.0) - assert_raises(IndexError, pd.detect_peaks, data, threshold, time[:len(time) / 2]) + assert_raises(IndexError, pd.detect_peaks, data, threshold, time[:int(len(time) / 2)]) peaks, troughs = pd.detect_peaks(data, threshold) assert_true(np.all(peaks == peak_indices), @@ -106,7 +106,7 @@ def test_detect_dynamic_peaks(): assert_raises(ValueError, pd.detect_dynamic_peaks, data, threshold, min_thresh, -1.0, time, pd.accept_peak_size_threshold) - assert_raises(IndexError, pd.detect_dynamic_peaks, data, threshold, min_thresh, 0.5, time[:len(time) / 2], + assert_raises(IndexError, pd.detect_dynamic_peaks, data, threshold, min_thresh, 0.5, time[:int(len(time) / 2)], pd.accept_peak_size_threshold) peaks, troughs = pd.detect_dynamic_peaks(data, threshold, min_thresh, 0.5, time, From 016eb406a5765d73623f4c6d3da30982de7352af Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Fri, 26 Oct 2018 17:07:26 +0200 Subject: [PATCH 3/5] [fakeFish] fix call of max --- thunderfish/fakefish.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thunderfish/fakefish.py b/thunderfish/fakefish.py index 271d7741..b39aac7e 100644 --- a/thunderfish/fakefish.py +++ b/thunderfish/fakefish.py @@ -280,7 +280,7 @@ def generate_pulsefish(frequency=100.0, samplerate=44100., duration=1., noise_st data = np.random.randn(len(time)) * noise_std period = 1.0/frequency jitter_std = period * jitter_cv - first_pulse = np.max(pulse_duration, 3.0*jitter_std) + first_pulse = np.max([pulse_duration, 3.0*jitter_std]) pulse_times = np.arange(first_pulse, duration, period ) pulse_times += np.random.randn(len(pulse_times)) * jitter_std pulse_indices = np.round(pulse_times * samplerate).astype(np.int) From 9dba8a070df609bd077cdcd019133a6c4a349ba9 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Fri, 26 Oct 2018 17:13:21 +0200 Subject: [PATCH 4/5] [harmonicgroup] change detection of listOfList --- thunderfish/harmonicgroups.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/thunderfish/harmonicgroups.py b/thunderfish/harmonicgroups.py index 0406048d..e5a9f20c 100644 --- a/thunderfish/harmonicgroups.py +++ b/thunderfish/harmonicgroups.py @@ -820,10 +820,9 @@ def fundamental_freqs(group_list): list_of_list = False for groups in group_list: for harmonic_group in groups: - if hasattr(harmonic_group, 'shape'): + if len(np.shape(harmonic_group)) > 1: list_of_list = True break - if list_of_list: fundamentals = [] for groups in group_list: From 3361b47f76898f38ed48792d97fe2a0a6ea5b2a6 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Fri, 26 Oct 2018 17:15:21 +0200 Subject: [PATCH 5/5] [voronoi] use int for indexing --- thunderfish/voronoi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thunderfish/voronoi.py b/thunderfish/voronoi.py index 36f1f0af..354645df 100644 --- a/thunderfish/voronoi.py +++ b/thunderfish/voronoi.py @@ -608,7 +608,7 @@ def random_points(self, n=None, poisson=True, mode='outer'): nn = n if poisson: nn = np.random.poisson(n) - m = nn/2 + m = nn//2 if m < 5: m = 5 # get bounding box: @@ -636,7 +636,7 @@ def random_points(self, n=None, poisson=True, mode='outer'): elif mode == 'bbox': points = np.vstack((points, newpoints[np.all(newpoints