-
Notifications
You must be signed in to change notification settings - Fork 985
Closed
Description
Summary
Add and refactor NumPy encoding tests in test_numpy.py to improve maintainability and add 2D array batch encoding test coverage.
Use Case
The NumPy encoding tests were lacked coverage for 2D array batch encoding scenarios. This refactoring:
- Adds 2D array testing - Ensures batch encoding works correctly for 2D NumPy arrays
- Follows pytest best practices - Removes unnecessary
if __name__ == "__main__":blocks - Improves maintainability - Uses helper functions and parameterized tests for cleaner code
Proposed Implementation
-
Added 2D array batch encoding tests
- Extended
test_encode_numpy_array()to test both 1D (single sample) and 2D (batch) arrays - Tests various batch sizes and qubit configurations
- Extended
-
Code cleanup
- Removed redundant
if __name__ == "__main__":block (pytest handles test discovery automatically) - Removed unnecessary print statements
- Fixed tests to only test implemented encoding methods (amplitude, not angle/basis)
- Removed redundant
-
Test coverage
- NumPy file format encoding (
.npyfiles) - 1D NumPy array encoding (single sample)
- 2D NumPy array encoding (batch)
- Different precision settings (float32, float64)
- Error handling (wrong dtype, unsupported dimensions)
- NumPy file format encoding (
Reactions are currently unavailable