quairkit.core.test¶
Common settings and utilities for the unit test
- quairkit.core.test.get_test_device_list()¶
Return the device list for tests.
Policy: - Always test CPU. - By default, do NOT expand to CUDA for the whole suite (many tests rely on CPU-only numpy/scipy paths).
You can opt-in by setting environment variable QUAIRKIT_TEST_ALL_DEVICES=1.
- quairkit.core.test.get_state_simulator_test_device_list()¶
Return the device list for StateSimulator-focused tests.
Policy: - Always test CPU. - Automatically include CUDA when available.
- class quairkit.core.test.PerformanceMonitor¶
Monitor performance metrics (time and memory) for test functions.
- property wall_time : float¶
Wall time in seconds.
- property memory_peak : float¶
Peak memory usage in MB.
- property memory_delta : float¶
Memory delta from start to peak in MB.
- to_dict()¶
Convert to dictionary for JSON serialization.
- quairkit.core.test.get_version()¶
Get the version from quairkit package.
- quairkit.core.test.get_commit_hash()¶
Get the git commit hash of the current repository.
-
quairkit.core.test.generate_test_report(test_results, output_dir=
None, format='json')¶ Generate a test performance report.
-
quairkit.core.test.generate_system_index_permutations(num_systems, num_acted, max_permutations=
None, include_sequential=True, include_shuffled=True, include_partial=True)¶ Generate various system index permutations for testing.
- Parameters:¶
- num_systems : int¶
Total number of systems.
- num_acted : int¶
Number of systems the operation acts on.
- max_permutations : int | None¶
Maximum number of permutations to generate. If None, generates all.
- include_sequential : bool¶
Include sequential indices like [0, 1, 2].
- include_shuffled : bool¶
Include shuffled indices.
- include_partial : bool¶
Include cases where not all systems are used.
- Returns:¶
List of system index lists.
- Return type:¶
List[List[int]]
-
quairkit.core.test.generate_batch_dimensions(default_range=
(1, 3), special_range=None)¶ Generate batch dimension combinations for testing.
-
quairkit.core.test.generate_system_dim_combinations(num_systems, default_dim_range=
(2, 3), qudit_combinations=None)¶ Generate system dimension combinations for testing.
-
quairkit.core.test.track_performance(test_name=
None)¶ Decorator to track performance of a test function.
Usage:
@track_performance("test_name") def test_xxx(): ...
- quairkit.core.test.get_test_performance_results()¶
Get all collected test performance results.
- quairkit.core.test.clear_test_performance_results()¶
Clear all collected test performance results.