-
Notifications
You must be signed in to change notification settings - Fork 1
Jump diffusion model #95
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #95 +/- ##
==========================================
Coverage ? 97.75%
==========================================
Files ? 31
Lines ? 1689
Branches ? 274
==========================================
Hits ? 1651
Misses ? 21
Partials ? 17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rozyczko
left a comment
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.
Good code. Only typos and minor issues found.
| @@ -1,17 +1,11 @@ | |||
| # SPDX-FileCopyrightText: 2025-2026 EasyDynamics contributors <https://github.com/easyscience> | |||
| # SPDX-License-Identifier: BSD-3-Clause | |||
|
|
|||
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.
Any particular reason you deleted the license header?
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.
Copy/paste from old code going wrong
| def create_component_collections( | ||
| self, | ||
| Q: Q_type, | ||
| component_display_name: str = 'Brownian translational diffusion', |
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.
This should probably say "Jump translational diffusion"
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.
See above haha
| """Create ComponentCollection components for the Brownian. | ||
|
|
||
| translational diffusion model at given Q values. Args: | ||
| ---------- Q : Number, list, or np.ndarray | ||
| Scattering vector values. | ||
| component_display_name : str | ||
| Name of the Brownian Diffusion Lorentzian component. | ||
| Returns | ||
| ------- | ||
| List[ComponentCollection] | ||
| List of ComponentCollections with Brownian Diffusion | ||
| Lorentzian components. | ||
| """ |
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.
same here s/Brownian/translational/g
| unit_conversion_factor_nominator = ( | ||
| self._hbar * self.diffusion_coefficient / (self._angstrom**2) |
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.
nominator -> did you mean numerator?
| angstrom = DescriptorNumber('angstrom', 1e-10, unit='m') | ||
|
|
||
|
|
||
| class TestJumpTranslationalDiffusion: |
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.
Missing tests for test_scale_setter and test_scale_setter_raises (since they are in the Brownian tests)
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.
I moved the scal setter and getter to diffusion_base, now the tests are also there
| except Exception as e: | ||
| raise UnitError( | ||
| f'Invalid unit: {unit}. Unit must be a string or scipp Unit and convertible to meV.' # noqa: E501 | ||
| f'Invalid unit: {unit}. Unit must be a string or scipp Unitand convertible to meV.' |
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.
typo: Unitand -> Unit and
| raise TypeError('Q must be a float.') | ||
|
|
||
| # Q is given as a float, so we need to add the units | ||
| return f'hbar * D* {Q} **2*1/(angstrom**2)/(1 + (D * t* {Q} **2/(angstrom**2)))' |
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.
Why the extra 1 in the expression?
Just {Q}**2 / (angstrom**2) should be fine
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.
I think I had problems with it related to the bug with order of operations when dividing parameters
seventil
left a comment
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.
lgtm, just nitpicks
| @@ -62,65 +57,35 @@ def __init__( | |||
| Defaults to "meV". | |||
| scale : float or Parameter, optional | |||
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.
typo here, scale is numeric
| # ------------------------------------------------------------------ | ||
| # dunder methods | ||
| # ------------------------------------------------------------------ | ||
|
|
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.
Same for diffusion_coefficient and all other repr I've made so far... I'll streamline them once I know what I want, which is after the Job class :) but it's a good point!
| # ------------------------------------------------------------------ | ||
| # dunder methods | ||
| # ------------------------------------------------------------------ | ||
|
|
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.
Same for diffusion_coefficient and all other repr I've made so far... I'll streamline them once I know what I want, which is after the Job class :) but it's a good point!
* jump diffusion model * fix notebook * fix weakref? * fix weakref? * fix weakref??? * ... * weakref... * claude fixed it? * respond to PR comments * Move scale test to base model and add some formatting * fix typo * small fix
Add Jump Diffusion and remove some unit options that were bugged in the Brownian diffusion. Also had Claude AI fix the weakref bug that had been driving me crazy. It's a temporary solution, but anything is better than getting these random errors that are not related to the code I've written.
Closes #78
closes #66 as irrelevant