Skip to content

Conversation

@sbillinge
Copy link
Contributor

to make them more widely available in general

to make them more wiedely available in general
raise ValueError(invalid_q_or_wavelength_emsg)


def q_to_tth(on_q, wavelength):
Copy link

Choose a reason for hiding this comment

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

I wonder if it might be better to have the function parameter be a Diffraction_object, and extract q and two theta from that object inside the body of the function. This would keep it consistent to the way it was before in that you can avoid having to reference instance variables in a function call. I might be wrong about this, but I don't think it's likely the functions would be used without diffraction objects, so this would be a bit of a "shorthand" compared to what it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion @8bitsam . I chose not to do that because then you would need to instantiate a DO before you could do a transform on your data. The point of pulling it out of the DO and into transforms was so that people who weren't using DOs could still use the transforms. Perhaps it would even make sense to not require a 2D np array which is uncommon for people to have in general (they often hand around 1D vector arrays). It does seem odd to have to break up our DO and then reformulate it, which is what results from this. I think this is not a problem if there is not performance issue, because the DO is using it as a private function. My initial intention was to make it a private function because no user ever using DOs will need to call it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was also thinking that maybe we shall pass in the x-array only, since we won't change anything to the intensity array in the function. It does seem to match with the DO better so maybe we should keep the 2D array.

return on_tth


def tth_to_q(on_tth, wavelength):
Copy link

Choose a reason for hiding this comment

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

Same comment as q_to_tth.


def tth_to_q(on_tth, wavelength):
r"""
Helper function to convert two-theta to q on independent variable axis.
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we only have our tth in degrees during the conversion while radian is also an option for x-array. We should specify this somewhere around here?

@codecov
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.31%. Comparing base (d3f83b2) to head (e55e44d).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   99.62%   97.31%   -2.31%     
==========================================
  Files           7        8       +1     
  Lines         265      261       -4     
==========================================
- Hits          264      254      -10     
- Misses          1        7       +6     
Files with missing lines Coverage Δ
...ils/scattering_objects/test_diffraction_objects.py 84.61% <100.00%> (-15.39%) ⬇️
tests/test_transforms.py 100.00% <100.00%> (ø)

@sbillinge sbillinge merged commit 49bb353 into diffpy:main Dec 2, 2024
4 of 5 checks passed
@sbillinge sbillinge deleted the private_f branch December 2, 2024 19:28
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.

3 participants