Skip to content
Open
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
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
exclude:
# Reduce matrix size - test fewer combinations on Windows/Mac
- os: windows-latest
Expand All @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -48,6 +48,12 @@ jobs:
python -m pip install --upgrade pip
pip install -e .[dev]

- name: Install and verify NumPy 2.x
if: ${{ matrix.python-version == '3.12' || matrix.python-version == '3.13' }}
run: |
python -m pip install "numpy>=2"
python -c "import numpy as np; major = int(np.__version__.split('.', 1)[0]); print('numpy', np.__version__); raise SystemExit(0 if major >= 2 else 1)"

- name: List installed packages
run: pip list

Expand Down
6 changes: 3 additions & 3 deletions causationentropy/core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def plot_causal_network(
)

# Get colors from colormap
cmap = plt.cm.get_cmap(colormaps[i % len(colormaps)])
cmap = plt.get_cmap(colormaps[i % len(colormaps)])
colors = cmap(norm_cmis)

# Modulate alpha by p-value if requested
Expand Down Expand Up @@ -562,7 +562,7 @@ def plot_causal_network(
# Create legend for lag groups
legend_elements = []
for i, lag in enumerate(sorted_lags):
colormap = plt.cm.get_cmap(colormaps[i % len(colormaps)])
colormap = plt.get_cmap(colormaps[i % len(colormaps)])
color = colormap(0.7)
legend_elements.append(
Patch(facecolor=color, edgecolor="black", label=f"Lag {lag}")
Expand All @@ -581,7 +581,7 @@ def plot_causal_network(
# Add colorbar showing CMI scale if requested
if show_colorbar and sorted_lags:
# Create colorbar for the first lag as representative
cmap = plt.cm.get_cmap(colormaps[0])
cmap = plt.get_cmap(colormaps[0])
sm = plt.cm.ScalarMappable(
cmap=cmap, norm=Normalize(vmin=0, vmax=global_max_cmi)
)
Expand Down
7 changes: 2 additions & 5 deletions causationentropy/core/stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from scipy.integrate import trapezoid


def auc(TPRs, FPRs):
Expand Down Expand Up @@ -72,11 +73,7 @@ def auc(TPRs, FPRs):
>>> print(f"Random AUC: {auc(tpr_random, fpr_random)}")
"""

# Use trapezoid for NumPy 2.0+, trapz for older versions
if hasattr(np, "trapezoid"):
AUC = np.trapezoid(TPRs, FPRs)
else:
AUC = np.trapz(TPRs, FPRs)
AUC = trapezoid(TPRs, FPRs)
return AUC


Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Mathematics",
Expand Down