tempoCollaboration / OQuPy

A Python package to efficiently simulate non-Markovian open quantum systems with process tensors.
https://oqupy.readthedocs.io
Apache License 2.0
71 stars 24 forks source link

Redesign defensive code #107

Open gefux opened 5 months ago

gefux commented 5 months ago

Currently the code checks the type of most input parameters given by the user. Though this might not be very Pythonic it is certainly useful to catch non-sensical input early on and provide the user with a helpful error message. However, this input checking is not done consistently and leads to a lot of boiler plate code. This should be made consistant and avoid boilerplate.

piperfw commented 1 month ago

A related point I found is that our use of optional arguments also seems inconsistent: we have optional arguments for internal functions that are always specified in the code (albeit sometimes with the special value None). I think we will always want to specify them in the backend code to be explicit, i.e., there is little reason for them to be optional.

degeneracy_maps in BaseTempoBackend is an example.

piperfw commented 3 weeks ago

Small bug that should be addressed with this issue.

If one provides a callable that returns a string rather than a float in the gammas argument of a System, _check_tdependent_gammas_linblad_operators passes but the actual calculation fails with a numpy error.

This is because _check_tdependent_gammas_linblad_operators just tries to convert the gamma to a float (which it can for a string) rather than assert that is the actual return type. There are likely other instances of this flaw in the code.