Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow readonly arrays for higuchi_fd #13

Merged
merged 1 commit into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions antropy/fractal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal functions"""
import numpy as np
from numba import jit
from numba import jit, types
from math import log, floor

from .entropy import num_zerocross
Expand Down Expand Up @@ -194,7 +194,7 @@ def katz_fd(x, axis=-1):
return kfd


@jit('float64(float64[:], int32)')
@jit((types.Array(types.float64, 1, 'C', readonly=True), types.int32))
def _higuchi_fd(x, kmax):
"""Utility function for `higuchi_fd`.
"""
Expand Down
4 changes: 4 additions & 0 deletions antropy/tests/test_fractal.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def test_higuchi_fd(self):
"""
# Compare with MNE-features
self.assertEqual(np.round(higuchi_fd(RANDOM_TS), 8), 1.9914198)
# Check if readonly arrays can be processed as well
x = RANDOM_TS.copy().astype(np.float64)
x.flags.writeable = False
self.assertEqual(np.round(higuchi_fd(x), 8), 1.9914198)
higuchi_fd(list(RANDOM_TS), kmax=20)

def test_detrended_fluctuation(self):
Expand Down