Skip to content

feat: getmud UC1 (get_diameter) #184

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yucongalicechen
Copy link
Collaborator

@yucongalicechen yucongalicechen commented May 6, 2025

Address UC1 in #166
@sbillinge ready for review

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.32%. Comparing base (53ee55d) to head (5fb2d48).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   99.31%   99.32%   +0.01%     
==========================================
  Files           5        6       +1     
  Lines         292      298       +6     
==========================================
+ Hits          290      296       +6     
  Misses          2        2              
Files with missing lines Coverage Δ
tests/test_getmud.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

xray_energy=args.energy,
sample_mass_density=args.mass_density,
)
print(f"Capillary Diameter: {diameter:.2f} mm")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current logic is that if the user enters get-diameter, it will load the compute_diameter function from getmud module. I'm not sure if printing the result is the best approach here. The CLI will look something like labpdfproc get-diameter 2 ZrO2 17.45 1.6.

"get-diameter", help="Compute capillary diameter."
)
get_d_parser.add_argument(
"mud", type=float, help="The target muD of the sample."
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will write a better help message with an example here

@sbillinge
Copy link
Contributor

closes #166 @sbillinge ready for review

I don't think this closes #166 which has multiple UCs in it. IF those UCs have been broken out as we intended, then we can manually close #166, and in this PR you want to close whicher of those granular issues this PR addresses.

@sbillinge
Copy link
Contributor

Is this an old PR somehow left over from before our conversation? I am looking forward to having a series of small PRs that do each of the sub-parts of the UCs we were discussion, and we can just close this PR? I left a few comments, but I htink they may not be relevant if we are doing the granular PRs

@yucongalicechen
Copy link
Collaborator Author

Is this an old PR somehow left over from before our conversation? I am looking forward to having a series of small PRs that do each of the sub-parts of the UCs we were discussion, and we can just close this PR? I left a few comments, but I htink they may not be relevant if we are doing the granular PRs

Yes, the old PR is in #175. As discussed, we need to separate PRs for UC1, UC3+4, CLI, and docs. This PR includes UC1 and its CLI app. I kept them in the same PR because the CLI directly calls the function, and having them together makes it easier to check how it works. Let me know if you think this makes sense!

@sbillinge
Copy link
Contributor

I think it is better if we split it up, one function per pr. Pls see my comment on this one, but the cli will be last because it won't work till all the functions are written and it can call them one after the other

@yucongalicechen
Copy link
Collaborator Author

I think it is better if we split it up, one function per pr. Pls see my comment on this one, but the cli will be last because it won't work till all the functions are written and it can call them one after the other

Okay. I didn't see any specific comments on this PR?

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

Sorry, I forgot to submit

from diffpy.utils.tools import compute_mu_using_xraydb


def compute_diameter(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function should just be

def get_diameter(mud, mu)
    return mud/mu

with docstrings etc. of course.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think previously we discussed that user enters chemical info related to mu, but not mu itself (See #175 (review))? Maybe a better approach here is to write return mud/compute_mu(composition, energy, density)?

Copy link
Contributor

Choose a reason for hiding this comment

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

A function that computes mu Is much more reusable. It should probably be in didn't. Utils though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sbillinge Sounds good, I edited the function and it's ready for another review. I removed the CLI here and created a new issue for it (#186).

@yucongalicechen yucongalicechen changed the title feat: getmud UC1 (compute_diameter) + CLI function feat: getmud UC1 (get_diameter) May 8, 2025
diameter : float
Computed capillary diameter in mm.
"""
return mud / compute_mu_using_xraydb(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better format - use compute_mu function from diffpy.utils.

@sbillinge
Copy link
Contributor

I don't think we need this function. If we have a compute_mu_from_xraydb then we can go straight to the CLI. We don't need a function that just does d = mud/mu. The CLI will get the inputs through a parser/Gooey gui, and then return the value.

We just have to decide what we want the user experience to be for that. A standalone app that just does that and has its own name, or having it as an optional part of labpdfrpoc. I can think about what I htink is better, but I don't have a clear idea. Maybe you can think about it too.

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.

2 participants