Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
57f9842
fix: replace pkg_resources with importlib.metadata for Python 3.12+ c…
ravenoak May 13, 2026
e05a11c
fix: migrate setuptools-scm from setup_requires to pyproject.toml bui…
ravenoak May 13, 2026
2961a51
fix: update numba, numpy, torch, pandas, networkx version constraints…
ravenoak May 13, 2026
311c8b6
ci: expand Python matrix to 3.10-3.14, upgrade Actions to v4
ravenoak May 13, 2026
51729a2
ci: update ReadTheDocs to Python 3.12 and ubuntu-24.04
ravenoak May 13, 2026
05b6cf2
test: remove blanket UserWarning suppression from pytest.ini
ravenoak May 13, 2026
862be95
chore: add Python 3.10-3.14 classifiers to setup.py
ravenoak May 13, 2026
6d3ff5e
fix: update publish workflow to Actions v4 with fetch-depth and add S…
ravenoak May 13, 2026
0aa0227
build: migrate to PEP 621 pyproject.toml, remove setup.py, adopt uv i…
ravenoak May 14, 2026
079e50e
fix: guard memory_profiler import, move to dev optional dependency
ravenoak May 14, 2026
f8f7620
merge: update from main (annotation function extensions, version bump)
ravenoak May 14, 2026
647d0e5
fix: replace numba.typed.List comprehensions with explicit loops for …
ravenoak May 14, 2026
bb538bc
fix: apply numba.typed.List loop fix to interpretation_parallel.py
ravenoak May 14, 2026
5e13bf7
fix: rename integer loop variable i to fi/ri/j in reason() to fix Num…
ravenoak May 14, 2026
a8d83ea
fix: resolve Numba type-unification and recursion failures on Python …
ravenoak May 14, 2026
c0cc566
fix: Python 3.11+ Numba compatibility in interpretation_fp.py; add Nu…
ravenoak May 14, 2026
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
24 changes: 14 additions & 10 deletions .github/workflows/python-package-version-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Cache Numba JIT artifacts
uses: actions/cache@v4
with:
path: pyreason/cache
key: numba-${{ matrix.python-version }}-${{ hashFiles('pyreason/scripts/**/*.py') }}
restore-keys: |
numba-${{ matrix.python-version }}-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff pytest
pip install torch==2.6.0
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
run: uv pip install --system -e ".[dev,torch]"
- name: Lint with ruff
run: |
python -m ruff check pyreason/scripts
run: python -m ruff check pyreason/scripts
- name: Pytest Unit Tests with JIT Disabled
run: |
pytest tests/unit/disable_jit --tb=short -q
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
9 changes: 6 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
version: 2

build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.9"
python: "3.12"

sphinx:
configuration: docs/source/conf.py

python:
install:
- requirements: requirements.txt
- method: pip
path: .
extra_requirements:
- docs
62 changes: 60 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,64 @@
[build-system]
requires = ['setuptools>=42']
build-backend = 'setuptools.build_meta'
requires = ["setuptools>=80", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "pyreason"
description = "An explainable inference software supporting annotated, real valued, graph based and temporal logic"
readme = "README.md"
license = { text = "BSD 3-Clause" }
authors = [
{ name = "Dyuman Aditya", email = "dyuman.aditya@gmail.com" }
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
]
requires-python = ">=3.10"
dynamic = ["version"]
dependencies = [
"networkx>=3.1",
"pyyaml>=6.0",
"pandas>=2.0.0",
"numba>=0.65.1",
"numpy>=2.1,<2.5",
]

[project.optional-dependencies]
torch = ["torch>=2.6.0"]
dev = [
"pytest",
"pytest-cov",
"pre-commit",
"ruff",
"memory_profiler",
]
docs = [
"sphinx",
"sphinx_rtd_theme",
"sphinx-autopackagesummary",
"sphinx-autoapi",
]

[project.urls]
Homepage = "https://github.com/lab-v2/pyreason"
"Bug Tracker" = "https://github.com/lab-v2/pyreason/issues"
Repository = "https://github.com/lab-v2/pyreason"

[tool.setuptools_scm]
fallback_version = "0.0.0"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["."]

[tool.ruff.lint]
# Ignore ambiguous variable name errors (E741) in interpretation files
Expand Down
13 changes: 8 additions & 5 deletions pyreason/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# ruff: noqa: F403 F405 (Ignore Pyreason import * for public api)
# Set numba environment variable
import os
import sys

# Python 3.11+ bytecode generates ~2300 CFG nodes for the large JIT-compiled
# reasoning functions; Numba's recursive DFS exceeds the default limit of 1000.
sys.setrecursionlimit(max(sys.getrecursionlimit(), 5000))
package_path = os.path.abspath(os.path.dirname(__file__))
cache_path = os.path.join(package_path, 'cache')
cache_status_path = os.path.join(package_path, '.cache_status.yaml')
Expand All @@ -9,13 +14,11 @@

from pyreason.pyreason import *
import yaml
from importlib.metadata import version
from pkg_resources import get_distribution, DistributionNotFound
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
__version__ = version(__name__)
except PackageNotFoundError:
pass


Expand Down
13 changes: 12 additions & 1 deletion pyreason/pyreason.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import time
import sys
import pandas as pd
import memory_profiler as mp
try:
import memory_profiler as mp
_has_memory_profiler = True
except ImportError:
mp = None
_has_memory_profiler = False
import warnings
from typing import List, Type, Callable, Tuple, Optional

Expand Down Expand Up @@ -1513,6 +1518,12 @@ def reason(timesteps: int = -1, convergence_threshold: int = -1, convergence_bou
if settings.output_to_file:
sys.stdout = open(f"./{settings.output_file_name}_{__timestamp}.txt", "a")

if settings.memory_profile and not _has_memory_profiler:
raise ImportError(
"memory_profiler is required for memory profiling. "
"Install it with: pip install memory_profiler"
)

if not again or __program is None:
if settings.memory_profile:
start_mem = mp.memory_usage(max_usage=True)
Expand Down
Loading