feat(python): Python Bindings

Python Bindings are working again
This commit is contained in:
2025-12-20 16:02:52 -05:00
parent d65c237b26
commit 11a596b75b
78 changed files with 4411 additions and 1110 deletions

View File

@@ -103,7 +103,7 @@ if __name__ == "__main__":
parser.add_argument('--suite', type=str, choices=[suite.name for suite in ValidationSuites], nargs="+", help="The validation suite to run.")
parser.add_argument("--all", action="store_true", help="Run all validation suites.")
parser.add_argument("--pynucastro-compare", action="store_true", help="Generate pynucastro comparison data.")
parser.add_argument("--pync-engine", type=str, choices=["GraphEngine", "MultiscalePartitioningEngineView", "AdaptiveEngineView"], default="AdaptiveEngineView", help="The GridFire engine to use to select the reactions for pyuncastro comparison.")
parser.add_argument("--pync-engine", type=str, choices=["GraphEngine", "MultiscalePartitioningEngineView", "AdaptiveEngineView"], default="AdaptiveEngineView", help="The GridFire engine to use to select the reactions for pynucastro comparison.")
args = parser.parse_args()
if args.all:

View File

@@ -9,7 +9,7 @@ from gridfire.engine import EngineTypes
from gridfire.policy import MainSequencePolicy
from gridfire.type import NetIn, NetOut
from gridfire.exceptions import GridFireError
from gridfire.solver import CVODESolverStrategy
from gridfire.solver import PointSolver, PointSolverContext
from logger import StepLogger
from typing import List
import re
@@ -221,16 +221,16 @@ class TestSuite(ABC):
with open(f"GridFireValidationSuite_{self.name}_pynucastro.json", "w") as f:
json.dump(pynucastro_json, f, indent=4)
def evolve(self, engine: DynamicEngine, netIn: NetIn, pynucastro_compare: bool = True, engine_type: EngineTypes | None = None):
solver : CVODESolverStrategy = CVODESolverStrategy(engine)
def evolve(self, engine: DynamicEngine, solver_ctx: PointSolverContext, netIn: NetIn, pynucastro_compare: bool = True, engine_type: EngineTypes | None = None):
solver : PointSolver = PointSolver(engine)
stepLogger : StepLogger = StepLogger()
solver.set_callback(lambda ctx: stepLogger.log_step(ctx))
solver_ctx.callback(lambda ctx: stepLogger.log_step(ctx))
startTime = time.time()
try:
startTime = time.time()
netOut : NetOut = solver.evaluate(netIn)
netOut : NetOut = solver.evaluate(solver_ctx, netIn)
endTime = time.time()
stepLogger.to_json(
f"GridFireValidationSuite_{self.name}_OKAY.json",