TeamGraphix / graphix

measurement-based quantum computing (MBQC) compiler and simulator
https://graphix.readthedocs.io
Apache License 2.0
55 stars 20 forks source link

Avoid using random numbers for tests #65

Open king-p3nguin opened 1 year ago

king-p3nguin commented 1 year ago

Is your feature request related to a problem? Please describe. The use of random numbers in testing can be cited as a reason why transpiler bugs were not found until recently. A simple way to avoid this is to fix the seed value, but the best approach is to increase the number of deterministic test cases that cover various scenarios without relying on random numbers.

Describe the feature you'd like Create as many test cases as possible to cover various scenarios in tests/test_pattern.py and tests/test_transpiler.py.

Additional context

shinich1 commented 1 year ago

@king-p3nguin thank you for the issue report! Actually we've added a new class of circuits in the tests: see here, random_circuit.py, and tests now run for 10 different realisations of this. Do you think it can be generalised/improved? Please let me know what you think.

king-p3nguin commented 1 year ago

@shinich1 In that case, I think it would be better to test all the circuits that get_rand_circuit can create instead of picking up certain circuits. It will definitely increase the time for testing, but since the pattern optimization is one of the most important features in graphix, it should not be a bad price to pay.

mgarnier59 commented 1 year ago

Also, we have starting using the hypothesispackage that is good at generating strategies and finding pathological cases. Sometimes it's a bit too much (like testing for NaN parameter values) but it can be very useful. We'll take a closer look at the testing strategy and give you feedback!