test_numbaModel
Unit tests for NumbaModel.
Section Topic ——- ———————————————————————- 1 Basic scalar I/O + memory namespace (smoke test) 2 Auto-convert scalar / list memory at Reset time 3 Post-Reset convenience writes via memory namespace 4 CurrentSimNanos parameter 5 IsLinked: scalar reader (unlinked, linked, becomes linked mid-sim) 6 Message chain: producer -> consumer (scalar I/O, memory) 7 List readers: all linked, partial link (IsLinked array) 8 List writers 9 Dict readers: key introspection, data round-trip, unlinked error 10 Dict writers 11 2-D memory array 12 moduleID parameter 13 Re-wiring: subscribeTo after Reset 14 Memory persistence across resets 15 Error cases (incl. empty containers, empty memory) 16 Dict reader IsLinked keyed access 17 bskLogger proxy
- class test_numbaModel.AutoConvertModel(*args, **kwargs)[source]
Bases:
NumbaModelModel used to verify scalar and list memory auto-conversion.
- class test_numbaModel.BasicModel(*args, **kwargs)[source]
Bases:
NumbaModelMinimal scalar input/output model with one integer memory field.
- class test_numbaModel.ConsumerModel(*args, **kwargs)[source]
Bases:
NumbaModelSink model that scales the producer output by a fixed factor.
- class test_numbaModel.DictInModel(*args, **kwargs)[source]
Bases:
NumbaModelDictionary-based input reader model used for key-order tests.
- class test_numbaModel.DictOutModel(*args, **kwargs)[source]
Bases:
NumbaModelOne input reader → two named output messages.
- class test_numbaModel.GuardedReaderModel(*args, **kwargs)[source]
Bases:
NumbaModelForwards payload when linked; writes sentinel −1 when unlinked.
- class test_numbaModel.MatrixMemoryModel(*args, **kwargs)[source]
Bases:
NumbaModelStores a 3×3 diagonal matrix; outputs the diagonal each tick.
- class test_numbaModel.ModuleIDModel(*args, **kwargs)[source]
Bases:
NumbaModelHelper model that captures the module ID seen by the compiled kernel.
- class test_numbaModel.MultiInModel(*args, **kwargs)[source]
Bases:
NumbaModelTwo input readers summed into one output.
- class test_numbaModel.MultiOutModel(*args, **kwargs)[source]
Bases:
NumbaModelOne input reader → two indexed output writers.
- class test_numbaModel.ProducerModel(*args, **kwargs)[source]
Bases:
NumbaModelSource model used to exercise chained message passing.
- class test_numbaModel.TimeRecorderModel(*args, **kwargs)[source]
Bases:
NumbaModelRecords the last simulation time and a tick counter in memory.
- test_numbaModel.test_2dMemoryArrayPythonWrite()[source]
Python-side assignment to a 2-D memory field propagates to the C buffer.
- test_numbaModel.test_autoConvertMemory()[source]
Check scalar and list memory fields are converted at reset.
- test_numbaModel.test_bsklogger()[source]
bskLog / bskLog1 inside UpdateStateImpl should not crash; logic must run.
- test_numbaModel.test_cacheDiskImplBodyChange(tmp_path)[source]
Edit
UpdateStateImplon disk between processes and require the new implementation to run.This verifies the full production invalidation chain. The implementation body hash changes, the fingerprint changes, a new wrapper file is emitted, and Numba recompiles the implementation after its source timestamp changes. A stale-cache bug would show up as process 2 still returning
11.0.
- test_numbaModel.test_cacheDiskReuseAfterInProcessClear()[source]
Clear _NBMODEL_CFUNC_CACHE, re-run same config → disk path gives correct result.
- test_numbaModel.test_cacheDiskSurvivesProcessRestart(tmp_path)[source]
Disk cache written in process 1 is used correctly by process 2.
- test_numbaModel.test_cacheImplIdentityIsolation()[source]
Two classes with same dtype/structure but different UpdateStateImpl must not share cfunc.
- test_numbaModel.test_cacheLoggerLevelRuntime(monkeypatch, tmp_path, capfd)[source]
Logger level is read at runtime; models with different levels share one cfunc.
- test_numbaModel.test_cacheMultipleResetsReusesCfunc()[source]
Re-running InitializeSimulation reuses the in-process cfunc (Tier 2 benefit).
- test_numbaModel.test_cacheNoDtypeCollision()[source]
Same class, different reader dtypes → distinct fingerprints, no in-process collision.
Regression test for the location-based idHash bug: md5(file:qualname) produced the same key for all instances of a class regardless of message-type configuration.
Two instances with identical dtype config share exactly one cfunc.
Two instances share one cfunc but each has its own
allPtrs_buffer, so outputs never bleed.
- test_numbaModel.test_currentSimNanos()[source]
Check the compiled model receives the current simulation time.
- test_numbaModel.test_dictIslinkedKeyed()[source]
Dict reader IsLinked is accessible by key name: dataInMsgIsLinked[‘a’].
- test_numbaModel.test_dictReaderData()[source]
Payload from each dict key is routed to the correct output field.
- test_numbaModel.test_dictReaderKeys()[source]
Key order is preserved and accessible from Python after Reset.
- test_numbaModel.test_dictWriter()[source]
Check dictionary-based output messages are written by key.
- test_numbaModel.test_emptyListReader()[source]
Empty list attribute is allowed; cfunc receives a zero-element array (never iterated).
- test_numbaModel.test_emptyMemory()[source]
No memory fields defined: ‘memory’ param still compiles as a valid (ignored) Record.
- test_numbaModel.test_errorIslinkedWithoutPayload()[source]
An IsLinked flag without a matching Payload param leaves the variable undefined in the generated wrapper, which Numba catches as a TypingError.
- test_numbaModel.test_errorMissingInMsg()[source]
Check Reset fails when a referenced input message is missing.
- test_numbaModel.test_errorNotOverridden()[source]
Check Reset fails when
UpdateStateImplis not overridden.
- test_numbaModel.test_errorNotStaticmethod()[source]
Check Reset fails when
UpdateStateImplis not static.
- test_numbaModel.test_errorUnlinkedWithoutIslinkedGuard()[source]
Declaring
InMsgPayloadwithoutInMsgIsLinkedcrashes at reset if a reader is unlinked.
- test_numbaModel.test_errorUnrecognisedParam()[source]
Check Reset fails when the compiled signature has an unknown parameter.
- test_numbaModel.test_islinkedBecomesLinkedMidSim()[source]
Reader starts unlinked; subscribed after first tick - cfunc picks it up.
- test_numbaModel.test_islinkedLinked()[source]
Subscribed reader → IsLinked is True; payload is forwarded.
- test_numbaModel.test_islinkedUnlinked()[source]
Unlinked reader → IsLinked is False; cfunc takes the else branch.
- test_numbaModel.test_listReaderPartialLink()[source]
reader[0] subscribed, reader[1] unlinked → only reader[0] contributes.
- test_numbaModel.test_memoryWritePersistsThroughReset()[source]
Both Python-side writes and cfunc-internal writes survive a subsequent Reset.
- test_numbaModel.test_messageChain()[source]
Check a NumbaModel output can feed another NumbaModel input.
- test_numbaModel.test_moduleIdParameter()[source]
Check the compiled model receives the owning module identifier.
- test_numbaModel.test_multipleResets()[source]
Reset always continues from the current buffer value; cfunc writes and Python writes are treated identically.