-
Notifications
You must be signed in to change notification settings - Fork 20
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
Deprecate Diffraction_object
, rename to DiffractionObject
#165
Conversation
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.
Two deprecation messages written 1) docstring level 2) class level
@@ -18,6 +19,20 @@ | |||
|
|||
|
|||
class Diffraction_object: | |||
"""FIXME: Add class docstring. | |||
|
|||
.. deprecated:: 3.5.1 |
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.
Following the numpy deprecation standards:
Ref: https://numpydoc.readthedocs.io/en/latest/format.html#deprecation-warning
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #165 +/- ##
==========================================
+ Coverage 99.17% 99.27% +0.09%
==========================================
Files 7 8 +1
Lines 243 274 +31
==========================================
+ Hits 241 272 +31
Misses 2 2
|
`DiffractionObject` to follow the class naming convention. | ||
""" | ||
|
||
warnings.warn( |
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.
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 looks good. Here I would maybe begin with the words "Diffraction_object is deprecated and will be removed....."
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.
Fixed
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.
Ready for review - learning how to handle deprecation more gracefully in our group.
We also need the new class and it's tests. I guess it makes sense to have it on the same PR? |
erge branch 'deprecate' of https://github.com/bobleesj/diffpy.utils into deprecate
Diffraction_object
, rename to DiffractionObject
@@ -26,3 +26,12 @@ diffpy.utils.scattering_objects.diffraction_objects module | |||
:members: | |||
:undoc-members: | |||
:show-inheritance: | |||
|
|||
|
|||
diffpy.utils.scattering_objects.diffraction_object module |
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.
API module created for DiffractionObject
@@ -0,0 +1,265 @@ | |||
from pathlib import Path |
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 comment above - new file since file name changed
|
||
|
||
class DiffractionObject: | ||
""" |
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 included docstrings for this class. Initially, I also created docstrings for each method within this class docstring above __init__
. However, when I rendered the documentation locally, I noticed duplicate entries, as the docstring for each method is provided already. Therefore, here, I’ve only included descriptions for the Parameters
and Aattributes
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.
In this PR, none was modified except the class name.
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 see. So this is a direct copy-paste to duplicate it and then change the name, so we have both and they are identical to each other?
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.
Yes, they are identical, direct copy.
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.
In that case maybe let's keep it that way and not make any changes, just the name change?
@sbillinge Ready for review, a few comments added via inline. Thank you. |
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.
File name has been changed from diffraction_objects
to diffraction_object
which carries DiffractionObject
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 is the filename changed? This would lead to an API change if we add an additional diffraction object in the future.
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.
using one class per file seems to be a modular approach. And considering this file is located under the scattering_objects
directory, we could add additional classes as separate files.
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.
doesn't this just add useless typing though?
from diffpy.utils.scattering_objects.diffraction_object import DiffractionObject
from diffpy.utils.scattering_objects.pdf_object import PdfObject
...
The point of the current structure is that all diffraction objects go in the diffraction_objects module. What is the advantage of putting one per module?
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.
For the useless typing, if we could utilize relative import, would this be a good solution below?
from diffpy.utils.scattering import DiffractionObject
from diffpy.utils.scattering import PdfObject
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.
also not sure if we want to call it as "Object" since we are utilizing a class and object is something we make with the class..
from diffpy.utils.scattering import Diffraction
from diffpy.utils.scattering import Pdf
This a bit more feels like pythonic?
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 doesn't quite convey what it does though. Diffraction is a method, a DiffractionObject is the result of a diffraction experiment. We could call it DiffractionDataset
or something. I kind of like DiffractionObject
though.
I thought the task was to bring the current naming more into PEP8 standard, not to do a refactor?
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.
few comments. Also, please check if there were tests for Diffraction_object
. If there were, we should leave them until Diffraction_object
is removed.
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 is the filename changed? This would lead to an API change if we add an additional diffraction object in the future.
class DiffractionObject: | ||
""" | ||
A class to manipulate diffraction data, supporting basic arithmetic operations and | ||
conversions between different diffraction data metrics such as Q, two-theta, and d-spacing. |
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.
change metrics
here to independent variables
?
|
||
Parameters | ||
---------- | ||
name : str, 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.
What is the difference between a parameter and an attribute here?
Also, per numpy standards, desriptions always start with "The" so wavelength would be "The wavelength of the radiation used in the diffraction experiment. Defaults to None." which, slightly magically, makes everything much more readable. Please change everywhere.
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.
Fixed - added "The" in the front. Ref: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html
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.
What is the difference between a parameter and an attribute here?
Fixed. Consistent now.
scat_quantity : str | ||
Description of the type of scattering data stored. | ||
on_q : list of numpy.ndarray | ||
A list containing two numpy arrays: [Q values, Intensities]. |
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.
The "the" constructions helps with these docstrings here, because we need a short statement of what this is, which is missing. In this case it could be "The diffraction intensities on a grid of Q" followed by something along the ines you already put (i.e., high level view followed by pertinent details).
|
||
def set_qs_from_range(self, begin_q, end_q, step_size=None, n_steps=None): | ||
""" | ||
create an array of linear spaced Q-values |
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.
linearly
---------- | ||
begin_q float | ||
the beginning angle | ||
end_q float |
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 we usually have colons here end_q: float
Thanks for the feedback I will address each in the afternoon. |
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 discussion comments.
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.
doesn't this just add useless typing though?
from diffpy.utils.scattering_objects.diffraction_object import DiffractionObject
from diffpy.utils.scattering_objects.pdf_object import PdfObject
...
The point of the current structure is that all diffraction objects go in the diffraction_objects module. What is the advantage of putting one per module?
|
||
|
||
class DiffractionObject: | ||
""" |
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 see. So this is a direct copy-paste to duplicate it and then change the name, so we have both and they are identical to each other?
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.
@sbillinge ready for review again. Thank you.
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.
Please see comments. I think we are trying to do a bit too much of a refactor here. I suggest we just do the name-change and the deprecation warnings.
If we want to remove extra typing we could simply put DiffractionObject
into scattering_objects.py
module. This might make more sense.
In the future I expect we might have a PdfObject, but also others in principle, like XanesObject, RamanObject, and so on.
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 doesn't quite convey what it does though. Diffraction is a method, a DiffractionObject is the result of a diffraction experiment. We could call it DiffractionDataset
or something. I kind of like DiffractionObject
though.
I thought the task was to bring the current naming more into PEP8 standard, not to do a refactor?
|
||
|
||
class DiffractionObject: | ||
""" |
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.
In that case maybe let's keep it that way and not make any changes, just the name change?
Yes, too much refactoring I agree (good discussions still It think). I created a new PR below, just focused on changing the name and deprecating it. |
No description provided.