Skip to content

Commit

Permalink
black .
Browse files Browse the repository at this point in the history
  • Loading branch information
PiethonProgram committed Sep 30, 2024
1 parent 51faba3 commit b93c229
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
8 changes: 2 additions & 6 deletions antropy/entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ def perm_entropy(x, order=3, delay=1, normalize=False):
"""
# If multiple delay are passed, return the average across all d
if isinstance(delay, (list, np.ndarray, range)):
return np.mean(
[perm_entropy(x, order=order, delay=d, normalize=normalize) for d in delay]
)
return np.mean([perm_entropy(x, order=order, delay=d, normalize=normalize) for d in delay])
x = np.array(x)
ran_order = range(order)
hashmult = np.power(order, ran_order)
Expand Down Expand Up @@ -442,9 +440,7 @@ def _numba_sampen(sequence, order, r):
prev_in_diff = int(abs(sequence[order] - sequence[offset + order]) >= r)
for idx in range(1, size - offset - order):
out_diff = int(abs(sequence[idx - 1] - sequence[idx + offset - 1]) >= r)
in_diff = int(
abs(sequence[idx + order] - sequence[idx + offset + order]) >= r
)
in_diff = int(abs(sequence[idx + order] - sequence[idx + offset + order]) >= r)
n_numerator += in_diff - out_diff
n_denominator += prev_in_diff - out_diff
prev_in_diff = in_diff
Expand Down
10 changes: 4 additions & 6 deletions antropy/fractal.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def katz_fd(x, axis=-1):

# max distance from first to all
horizontal_diffs = np.arange(1, x.shape[axis])
vertical_diffs = np.take(
x, indices=np.arange(1, x.shape[axis]), axis=axis
) - np.take(x, indices=[0], axis=axis)
vertical_diffs = np.take(x, indices=np.arange(1, x.shape[axis]), axis=axis) - np.take(
x, indices=[0], axis=axis
)

if axis == 1: # reshape if needed
horizontal_diffs = horizontal_diffs.reshape(1, -1)
Expand All @@ -209,9 +209,7 @@ def katz_fd(x, axis=-1):

# Katz Fractal Dimension Calculation
full_distance = np.log10(total_path_length / average_path_length)
kfd = np.squeeze(
full_distance / (full_distance + np.log10(max_distance / total_path_length))
)
kfd = np.squeeze(full_distance / (full_distance + np.log10(max_distance / total_path_length)))

# ensure scalar output
if not kfd.ndim:
Expand Down
4 changes: 1 addition & 3 deletions antropy/tests/test_entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def test_spectral_entropy(self):
spectral_entropy(RANDOM_TS, SF_TS, method="fft")
spectral_entropy(RANDOM_TS, SF_TS, method="welch")
spectral_entropy(RANDOM_TS, SF_TS, method="welch", nperseg=400)
self.assertEqual(
np.round(spectral_entropy(RANDOM_TS, SF_TS, normalize=True), 1), 0.9
)
self.assertEqual(np.round(spectral_entropy(RANDOM_TS, SF_TS, normalize=True), 1), 0.9)
self.assertEqual(np.round(spectral_entropy(PURE_SINE, 100), 2), 0.0)
# 2D data
params = dict(sf=SF_TS, normalize=True, method="welch", nperseg=100)
Expand Down
4 changes: 1 addition & 3 deletions antropy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def _embed(x, order=3, delay=1):
# pre-defiend an empty list to store numpy.array (concatenate with a list is faster)
embed_signal_length = N - (order - 1) * delay
# define the new signal length
indice = [
[(i * delay), (i * delay + embed_signal_length)] for i in range(order)
]
indice = [[(i * delay), (i * delay + embed_signal_length)] for i in range(order)]
# generate a list of slice indice on input signal
for i in range(order):
# loop with the order
Expand Down

0 comments on commit b93c229

Please sign in to comment.