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

25 bug axes are switched #29

Merged
merged 2 commits into from
Apr 21, 2024
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
14 changes: 7 additions & 7 deletions pyPTE/core/pyPTE.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def compute_PTE(phase: npt.NDArray, delay: int) -> npt.NDArray:
for i in range(0, m):
for j in range(0, m):

ypr = phase[delay:, j]
y = phase[:-delay, j]
x = phase[:-delay, i]
ypr = phase[j, delay:]
y = phase[j, :-delay]
x = phase[i, :-delay]

P_y = np.zeros([y.max() + 1])
np.add.at(P_y, [y], 1)
Expand All @@ -154,10 +154,10 @@ def compute_PTE(phase: npt.NDArray, delay: int) -> npt.NDArray:
max_dim_ypr_y_x = max(ypr.max(), y.max(), x.max()) + 1
P_ypr_y_x = np.zeros([max_dim_ypr_y_x, max_dim_ypr_y_x, max_dim_ypr_y_x])

P_y /= m - delay
P_ypr_y /= m - delay
P_y_x /= m - delay
P_ypr_y_x /= m - delay
P_y /= n - delay
P_ypr_y /= n - delay
P_y_x /= n - delay
P_ypr_y_x /= n - delay

Hy = -np.nansum(np.multiply(P_y, np.log2(P_y)))
Hypr_y = -np.nansum(np.nansum(np.multiply(P_ypr_y, np.log2(P_ypr_y))))
Expand Down
5 changes: 4 additions & 1 deletion tests/test_pyPTE.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest

from pyPTE.core.pyPTE import (
PTE,
Expand Down Expand Up @@ -48,7 +49,9 @@ def test_function_shapes():
assert raw_PTE.shape == (4, 4), (
f"Expected dPTE shape (4, 4), got {dPTE.shape}")


@pytest.mark.xfail(
reason="This test will fail, because PTE values are not normalized \
and tolerances are to be defined")
def test_PTE_with_independent_signals():
signal_length = 1000
s1 = np.random.normal(0, 1, signal_length)
Expand Down
Loading