-
Notifications
You must be signed in to change notification settings - Fork 18
test/func: created a test and function for MorphFuncy #186
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
+ Coverage 96.99% 97.11% +0.12%
==========================================
Files 19 20 +1
Lines 831 866 +35
==========================================
+ Hits 806 841 +35
Misses 25 25
🚀 New features to boost your workflow:
|
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.
wow, fantastic. I few tiny cosmetic comments, but you nailed it in one shot as far as I can tell!
import pytest | ||
|
||
from diffpy.morph.morphs.morphfuncy import MorphFuncy | ||
|
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 these functions would be better with single blank lines between them.
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 am trying to delete these but every time I commit the files are modified by the hooks. I think this is the pre-commit?
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.
OK,, we can let it slide. It is because normally we want the functions well separated, but wehn we are defining a bunch of them for testing we just want them kind of closed up, but it is not a big deal.
Just fix the docstring and I can merge this.
morph = MorphFuncy() | ||
morph.function = function | ||
morph.parameters = parameters | ||
x_morph_actual, y_morph_actual, x_target_actual, y_target_actual = ( |
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.
Is there a reason you have the function call inside parens? It should work the same way without these and this is somewhat unconventional and therefore distracting?
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 is same as comment above, this is modified by the hooks.
------- | ||
Import the funcy morph function: | ||
>>> from diffpy.morph.morphs.morphfuncy import MorphFuncy | ||
Define or import the user-supplied transformation function: |
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 wonder if this would be easier to read with judiciously placed blank lines, maybe after each code block, but play around till it looks nice? I am not sure if there is a docstring standard for this, in which case follow it, but if not, then I think a few blank lines could increase readability.
Thanks Simon! This is your mentoring ... after MorphSqueeze I did learn a lot. |
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.
pls see inline
import pytest | ||
|
||
from diffpy.morph.morphs.morphfuncy import MorphFuncy | ||
|
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.
OK,, we can let it slide. It is because normally we want the functions well separated, but wehn we are defining a bunch of them for testing we just want them kind of closed up, but it is not a big deal.
Just fix the docstring and I can merge this.
@sbillinge should I work on MorphFuncx? Do we want to do the same as MorphFuncy but applied to the x-axis and then return the morphed data in the same grid as the input morph data? It would also be good if I could see the code for PDFgetX3, I can't find it in github. |
I do want this functionality in the fullness of time, and it should be relatively straightforward because we have the squeeze morph that uses a "particular" function which was the polynomial. So it should be relatively quick, almost a copy-paste. However, I would rather push next to see if we can figure out how to use a getX3 function to do the moprh onto the synchrtron data...... |
Sounds great to me! |
let me go and dig that up. This code is not open source..... |
I have created a draft for the
MorphFuncy
class and tested it using different functions with various parameters that I have defined usingpytest.parametrize
. I am currently defining the parameters for the functions as a dictionary, where each function has its specific parameters. I'm unsure if using a dictionary is the best decision. We can implement more options such as if the user does not provide a function to raise a warning or something similar.