Is it possible to write a useful test for DetectorDatabase.version?
At the moment, it is up to the coder to realise when their code changes mean that the version number on DetectorDatabase should be increased.
Ideally there would be an automated test for this. It won't be possible to write a test to cover all bases, but is a test which covers some easy/common cases possible and better than nothing?
Possibly also if we had a document of "things to consider when pushing code", we should add "Consider whether the version number of DetectorDatabase should be increased as a result of your changes" to it.
I thought about that. I can see two ways to do that:
- Include information about plaquettes into the
DetectorDatabase. - Re-compute the detectors and check that we have the same result.
I am in favor of 1, because it seems less costly in terms of resources.
In my mind, 1) would consist in:
- adding a
dict[str, T]to associate something of typeTthat identifies the circuit implemented by the plaquette (Tcan be directly astim.Circuit, or a hash of the circuit, ...) whose name is the key of the dictionary, - when a query is made, check that the plaquettes provided have the same instance of
T.
We could add a cache to make that check once per plaquette the first time it is encountered.
Not sure how that would impact performance though.