tqec icon indicating copy to clipboard operation
tqec copied to clipboard

Is it possible to write a useful test for DetectorDatabase.version?

Open BSchelpe opened this issue 6 months ago • 1 comments

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.

BSchelpe avatar Jun 19 '25 16:06 BSchelpe

I thought about that. I can see two ways to do that:

  1. Include information about plaquettes into the DetectorDatabase.
  2. 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 type T that identifies the circuit implemented by the plaquette (T can be directly a stim.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.

nelimee avatar Jun 20 '25 07:06 nelimee