Comprehensive refactoring: improve code quality, remove dead code, and enhance API #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a comprehensive refactoring of the pytmat codebase to address code quality issues, remove technical debt, and improve the user experience while maintaining full backward compatibility.
🔧 Key Improvements
Dead Code Removal
TCoefficientsandRCoefficientsstructs (~50 lines of dead code)add()functionCode Organization & Maintainability
optical_mathmodule with reusable mathematical functions:cos_refraction_angle()- Calculate refraction angles using Snell's lawfresnel_coefficients()- Compute TE/TM reflection and transmission coefficientspropagation_matrix()- Generate layer propagation matricesinterface_matrix()- Create interface transfer matricestransfer_for_wavelengthimplementations into single methodTWO_PI,ONE,ZERO,PARALLEL_THRESHOLD) to eliminate magic numbersEnhanced Python API
The Python interface now provides both legacy compatibility and modern usability:
Input Validation & Error Handling
Performance Optimizations
OnceCell🧪 Quality Assurance
.gitignoreto exclude build artifacts📈 Impact
This refactoring significantly improves code maintainability and user experience:
The changes represent best practices in Rust development while preserving the existing API for seamless upgrades.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.