Skip to content
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
27 changes: 11 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
exclude: 'pyreason/\.cache_status\.yaml'
exclude: 'pyreason/\.cache_status\.yaml|pyreason/scripts/interpretation/interpretation_parallel\.py'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
name: Fix end of files
exclude: 'pyreason/scripts/interpretation/interpretation_parallel\.py'
stages: [pre-commit]

- repo: local
hooks:
# --- COMMIT STAGE: Fast unit tests only ---
- id: ruff-check
name: Run ruff linter
entry: .venv/bin/python -m ruff check pyreason/scripts
entry: ruff check pyreason/scripts
language: system
types: [python]
pass_filenames: false
stages: [pre-commit]

- id: sync-interpretation-parallel
name: Sync interpretation_parallel.py from interpretation.py
entry: .venv/bin/python sync_interpretation_parallel.py
language: system
pass_filenames: false
files: 'pyreason/scripts/interpretation/interpretation\.py'
stages: [pre-commit]


- id: pytest-unit-no-jit
name: Run JIT-disabled unit tests
entry: .venv/bin/python -m pytest tests/unit/disable_jit -m "not slow" --tb=short -q
entry: pytest tests/unit/disable_jit --tb=short -q
language: system
pass_filenames: false
stages: [pre-commit]
require_serial: true

- id: pytest-unit-jit
name: Run JIT-enabled unit tests
entry: .venv/bin/python -m pytest tests/unit/dont_disable_jit -m "not slow" --tb=short -q
entry: pytest tests/unit/dont_disable_jit --tb=short -q
language: system
pass_filenames: false
stages: [pre-commit]
require_serial: true

# --- PUSH STAGE: Complete test suite ---
- id: pytest-unit-api
name: Run pyreason api tests
entry: .venv/bin/python -m pytest tests/api_tests --tb=short -q
entry: pytest tests/api_tests --tb=short -q
language: system
pass_filenames: false
stages: [pre-push]

- id: pytest-functional-complete
name: Run functional test suite
entry: .venv/bin/python -m pytest tests/functional/ --tb=short -q
entry: pytest tests/functional/ --tb=short -q
language: system
pass_filenames: false
stages: [pre-push]
stages: [pre-push]
14 changes: 9 additions & 5 deletions pyreason/scripts/interpretation/interpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,10 @@ def _update_node(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down Expand Up @@ -1628,7 +1630,7 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
world.world[p1].set_lower_upper(lower, upper)
world.world[p1].set_static(static)
ip_update_cnt += 1
updated_bnds.append(world.world[p2])
updated_bnds.append(world.world[p1])
if store_interpretation_changes:
rule_trace.append((numba.types.uint16(t_cnt), numba.types.uint16(fp_cnt), comp, p1, interval.closed(lower, upper)))

Expand All @@ -1641,8 +1643,10 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down
14 changes: 9 additions & 5 deletions pyreason/scripts/interpretation/interpretation_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,8 +1655,10 @@ def _update_node(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down Expand Up @@ -1742,7 +1744,7 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
world.world[p1].set_lower_upper(lower, upper)
world.world[p1].set_static(static)
ip_update_cnt += 1
updated_bnds.append(world.world[p2])
updated_bnds.append(world.world[p1])
if store_interpretation_changes:
rule_trace.append((numba.types.uint16(t_cnt), numba.types.uint16(fp_cnt), comp, p1, interval.closed(lower, upper)))

Expand All @@ -1755,8 +1757,10 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down
14 changes: 9 additions & 5 deletions pyreason/scripts/interpretation/interpretation_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,10 @@ def _update_node(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down Expand Up @@ -1628,7 +1630,7 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
world.world[p1].set_lower_upper(lower, upper)
world.world[p1].set_static(static)
ip_update_cnt += 1
updated_bnds.append(world.world[p2])
updated_bnds.append(world.world[p1])
if store_interpretation_changes:
rule_trace.append((numba.types.uint16(t_cnt), numba.types.uint16(fp_cnt), comp, p1, interval.closed(lower, upper)))

Expand All @@ -1641,8 +1643,10 @@ def _update_edge(interpretations, predicate_map, comp, na, ipl, rule_trace, fp_c
if current_bnd != prev_t_bnd:
if convergence_mode=='delta_bound':
for i in updated_bnds:
lower_delta = abs(i.lower-prev_t_bnd.lower)
upper_delta = abs(i.upper-prev_t_bnd.upper)
# Use each bound's own previous values instead of L's previous
prev_i_bnd = interval.closed(i.prev_lower, i.prev_upper)
lower_delta = abs(i.lower - prev_i_bnd.lower)
upper_delta = abs(i.upper - prev_i_bnd.upper)
max_delta = max(lower_delta, upper_delta)
change = max(change, max_delta)
else:
Expand Down
Loading