-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/coupling expansion #73
Conversation
Reviewer's Guide by SourceryThis pull request introduces significant enhancements to the codebase, including support for HDMI drivers, improved coupling mechanisms, and enhanced code quality through formatting and linting. The changes primarily focus on expanding the functionality of the magnetic junction simulation system while improving code organization and maintainability. Class diagram for updated Driver classesclassDiagram
class Driver {
- T constantValue
- T amplitude
- T frequency
- T phase
- T period
- T cycle
- T timeStart
- T timeStop
- UpdateType update
+ Driver()
+ Driver(UpdateType, T, T, T, T, T, T, T, T)
+ getCurrentScalarValue(T&): T
+ setConstantValue(T&)
+ phaseShift(T&)
}
class ScalarDriver {
- T edgeTime
- T steadyTime
+ ScalarDriver(UpdateType, T, T, T, T, T, T, T, T, T, T)
+ getCurrentScalarValue(T&): T
+ getConstantDriver(T): ScalarDriver
+ getPulseDriver(T, T, T, T): ScalarDriver
+ getSineDriver(T, T, T, T): ScalarDriver
+ getPosSineDriver(T, T, T, T): ScalarDriver
+ getHalfSineDriver(T, T, T, T): ScalarDriver
+ getStepDriver(T, T, T, T): ScalarDriver
+ getTrapezoidDriver(T, T, T, T, T): ScalarDriver
+ getGaussianImpulseDriver(T, T, T, T): ScalarDriver
+ getGaussianStepDriver(T, T, T, T): ScalarDriver
+ getUnitAxis(): CVector<T>
+ operator*(T): ScalarDriver
+ operator*=(T): ScalarDriver
+ operator+(T): ScalarDriver
+ operator+=(T): ScalarDriver
}
class AxialDriver {
- std::vector<ScalarDriver<T>> drivers
+ AxialDriver()
+ AxialDriver(ScalarDriver<T>, ScalarDriver<T>, ScalarDriver<T>)
+ getVectorAxialDriver(T, T, T): AxialDriver
+ applyMask(std::vector<unsigned int>)
+ applyMask(CVector<T>)
+ getCurrentAxialDrivers(T): CVector<T>
+ getConstantValues(): CVector<T>
+ getUnitAxis(): CVector<T>
}
Driver <|-- ScalarDriver
Driver <|-- AxialDriver
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @LemurPwned - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 12 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 5 issues found
- 🟢 Complexity: all looks good
- 🟡 Documentation: 1 issue found
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
…o feat/ruff-transition
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Feat/ruff transition + IDMI
Feat/fmr dynamic
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Feat/reservoir interaction
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @LemurPwned - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding more unit tests to cover the new HDMI and phase offset functionality
Here's what I looked at during the review
- 🟡 General issues: 7 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
elementIndx % this->cols); | ||
const tensor getDipoleTensorFromRelPositions(const CVector<double> &r1, | ||
const CVector<double> &r2) { | ||
const CVector<double> rij = r1 - r2; // 1-2 distance vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add check for zero distance between points to avoid numerical instability
When points are very close, the dipole tensor calculation can become numerically unstable. Consider adding a minimum distance check.
const CVector<double> rij = r1 - r2; // 1-2 distance vector | |
const CVector<double> rij = r1 - r2; | |
if (rij.length() < 1e-10) { | |
throw std::runtime_error("Points are too close for stable dipole calculation"); | |
} |
// } | ||
return dipoleTensor; | ||
public: | ||
GroupInteraction(std::vector<CVector<double>> coordinateMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Move coordinate vector validation earlier in constructor
Validate coordinate vectors before copying to avoid unnecessary operations when validation fails.
GroupInteraction(std::vector<CVector<double>> coordinateMatrix, | |
GroupInteraction(const std::vector<CVector<double>>& coordinateMatrix, |
return *this; | ||
} | ||
|
||
CVector operator/(T val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Add zero division check in operator/= to match operator/ implementation
The operator/= member function should include the same zero division check that exists in operator/ to maintain consistency and prevent potential crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a check for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback, we will generate fewer comments like this in the future according to the following instructions:
- Ensure the comment addresses a specific issue or improvement in the code.
- Verify that the comment provides a clear explanation of the problem and suggests a solution.
- Check if the comment is relevant to the current code changes and not redundant with existing checks or logic.
- Confirm that the comment maintains consistency with the overall codebase practices.
def test_driver_ops(): | ||
driver = sineDriver(10, 20, 1, 0) | ||
assert driver.getCurrentScalarValue(1 / 4) == 30 | ||
driver *= 2 | ||
assert driver.getCurrentScalarValue(1 / 4) == 60 | ||
|
||
driver = sineDriver(10, 20, 1, 0) | ||
driver += 2 | ||
assert driver.getCurrentScalarValue(1 / 4) == 34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Test case should verify error handling for driver operations
The test verifies basic arithmetic operations but doesn't check error cases. Consider adding tests for invalid operations (e.g. multiplying by zero, negative values) and edge cases.
def test_driver_ops():
driver = sineDriver(10, 20, 1, 0)
assert driver.getCurrentScalarValue(1 / 4) == 30
driver *= 2
assert driver.getCurrentScalarValue(1 / 4) == 60
with pytest.raises(ValueError):
driver *= 0
with pytest.raises(ValueError):
driver *= -1
driver = sineDriver(10, 20, 1, 0)
driver += 2
assert driver.getCurrentScalarValue(1 / 4) == 34
Summary by Sourcery
Expand the functionality of the AxialDriver and ScalarDriver classes with new methods and overloads. Enhance the Stack class with phase offset and effective coupling strength handling. Improve documentation and error handling across multiple modules. Update the pre-commit configuration and add new test cases for driver operations.
New Features:
Enhancements:
Documentation:
Tests:
Chores: