Description
When specula.init() is not called before creating SPECULA objects, the global variables global_precision and default_target_device_idx remain None.
This causes issues when initializing BaseTimeObj and any objects that inherit from it.
Current Behavior
If specula.init() is not called, objects can be created but may behave unexpectedly or fail with confusing errors.
The uninitialized state is not caught early, leading to difficult debugging.
Proposed Solution
A warning is issued when BaseTimeObj detects uninitialized globals, and it falls back to safe defaults (CPU device with single precision).
Alternative Approaches
Raise an error (stricter): Force users to explicitly call specula.init() before creating any objects.
@alfiopuglisi and @FabioRossiArcetri:
Should we maintain the current warning approach or switch to raising a RuntimeError to enforce explicit initialization?
Description
When
specula.init()is not called before creating SPECULA objects, the global variablesglobal_precisionanddefault_target_device_idxremain None.This causes issues when initializing
BaseTimeObjand any objects that inherit from it.Current Behavior
If
specula.init()is not called, objects can be created but may behave unexpectedly or fail with confusing errors.The uninitialized state is not caught early, leading to difficult debugging.
Proposed Solution
A warning is issued when
BaseTimeObjdetects uninitialized globals, and it falls back to safe defaults (CPU device with single precision).Alternative Approaches
Raise an error (stricter): Force users to explicitly call
specula.init()before creating any objects.@alfiopuglisi and @FabioRossiArcetri:
Should we maintain the current warning approach or switch to raising a RuntimeError to enforce explicit initialization?