Skip to content

Python Interfacing for PDFmorph (Clean Branch) #191

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

Merged
merged 9 commits into from
Jun 27, 2025

Conversation

Sparks29032
Copy link
Collaborator

@Sparks29032 Sparks29032 commented Apr 29, 2025

Todo:

  • Add tests
  • Add news
  • Edit functions or function descriptions to include some common kwargs
  • Add tutorial rst

Closes #212

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 99.00990% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.58%. Comparing base (a8f53ae) to head (a94021a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tests/test_morphpy.py 98.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   97.44%   97.58%   +0.14%     
==========================================
  Files          20       21       +1     
  Lines         978     1078     +100     
==========================================
+ Hits          953     1052      +99     
- Misses         25       26       +1     
Files with missing lines Coverage Δ
tests/test_morphio.py 100.00% <100.00%> (ø)
tests/test_morphpy.py 98.83% <98.83%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sparks29032 Sparks29032 mentioned this pull request Apr 29, 2025
5 tasks
@Sparks29032 Sparks29032 reopened this Apr 29, 2025
@sbillinge
Copy link
Contributor

@Luiskitsu please could you look at this. We may have battling pianos here so i want to synchronize efforts. Also, this is a big PR that is coming from a bunch of work we were doing at another XFEL beamtime and it is hard to review such a big PR so more eyes on it would be good. In general, it would be good to arrange a quick face to face meeting to discuss everything and make sure we are pushing together in the same direction.

@Sparks29032
Copy link
Collaborator Author

Force push as previous branch not up to date with recent updates.

@sbillinge
Copy link
Contributor

I don't like merging force-pushes as they can break everything. Is there a reason you didn't merge to preserve the git history?

@Sparks29032
Copy link
Collaborator Author

Sparks29032 commented Jun 26, 2025

There is some merged branch where the files morphpy and test_morphpy were touched (created then deleted), when they should not have been as this branch is supposed to introduce those files. Rebasing reset all the commits in those files prior to this branch, so either way commit history would've been lost. This branch had a lot more work, so I force pushed. No commits on this PRs history were touched by the force push.

Note that the commit history of all other files (other than the two new ones) are preserved.

@Sparks29032
Copy link
Collaborator Author

Sparks29032 commented Jun 26, 2025

@sbillinge Ready for review. Documentation added, and the new testdata file displays how the parameters of these two new morphs (squeeze and funcy) are displayed on command-line and when saved in the file information. Saving the morphing info can be toggled through the verbose parameter.

Comment on lines +578 to +591
# Shift
# Only enable hshift is squeeze is not enabled
if (
opts.hshift is not None and squeeze_poly_deg < 0
) or opts.vshift is not None:
chain.append(morphs.MorphShift())
if opts.hshift is not None and squeeze_poly_deg < 0:
hshift_in = opts.hshift
config["hshift"] = hshift_in
refpars.append("hshift")
if opts.vshift is not None:
vshift_in = opts.vshift
config["vshift"] = vshift_in
refpars.append("vshift")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works better when shifts are done last.

@Sparks29032
Copy link
Collaborator Author

Tutorial files (excluding the Full Parameter List):
image
image
image
image

assert pytest.approx(morph_info["funcy"]["s"]) == 2.5


if __name__ == "__main__":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just remove this in a future PR to get rid of this codecov problem

@sbillinge
Copy link
Contributor

I am merging this as it is beautiful but a few comments. First, it is way too big of a PR making review very difficult. I would prefer it is it were on at least 3 PRs (maybe one per check-list point)!

I don't want to look through it again, so I am just merging it, but to get rid the thing triggering codecov, we should just delete that "if name == main` block. It is not needed with pytest unless there is some special reason you are using it.

@sbillinge sbillinge merged commit b350d85 into diffpy:main Jun 27, 2025
5 checks passed
@Sparks29032
Copy link
Collaborator Author

Ill just remove that code. It's not being used by anything.

@Sparks29032
Copy link
Collaborator Author

I am merging this as it is beautiful but a few comments. First, it is way too big of a PR making review very difficult. I would prefer it is it were on at least 3 PRs (maybe one per check-list point)!

That's true, the documentation and code should have definitely been split up. Integrating funcy could have also been done on a separate PR.

@sbillinge
Copy link
Contributor

in general, one thing per PR is the best, except in rare circumstances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible API migration
2 participants