v0.4.2: Comprehensive Error Handling
π‘οΈ Major Error Handling Improvements
This release completely eliminates crashes and provides robust error handling for invalid inputs.
π― Key Fixes
- No more crashes: Eliminated "Fatal Python error: Aborted" when using invalid parameters
- Proper exceptions: Rust errors now convert to Python
ValueErrorexceptions - Input validation: Comprehensive validation for modulus, NaN values, and matrix formats
- System stability: Errors don't crash the Python interpreter
β¨ Error Handling Features
Non-Prime Modulus Handling
# Before: CRASH with "Fatal Python error: Aborted"
# After: Proper exception
try:
result = canns_ripser.ripser(points, coeff=4) # 4 is not prime
except ValueError as e:
print(f"Error: {e}") # "Modulus must be prime..."NaN Input Validation
- NaN values in distance matrices are detected and raise clear error messages
- Sparse matrices with NaN values are properly validated
- Invalid matrix dimensions are caught gracefully
System Recovery
- After encountering an error, the system continues working normally
- No need to restart Python interpreter after invalid inputs
π§ Technical Improvements
- Result-based error handling: All Rust functions use
Result<T, String>types - Error propagation: Proper error chains from Rust to Python
- Input validation: Comprehensive validation at all entry points
- Zero panics: Eliminated all
panic!()calls in favor of recoverable errors
π Compatibility & Performance
- β Full backward compatibility: No breaking changes to API
- β Zero performance impact: Error handling only activates on invalid inputs
- β Maintains all optimizations: Performance improvements from v0.4.0/v0.4.1 retained
π§ͺ Testing
- Added comprehensive error handling test suite
- Verified error recovery and system stability
- All existing functionality tests continue to pass
π User Benefits
- Better developer experience: Clear error messages instead of cryptic crashes
- Production stability: Applications can handle errors gracefully
- Debugging friendly: Proper Python stack traces for all error conditions
- Pythonic interface: Follows Python exception handling conventions
This release makes CANNS-Ripser much more robust and user-friendly while maintaining its high-performance characteristics.