Skip to content
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

Rename id to uuid in DiffractionObject #271

Merged
merged 8 commits into from
Dec 26, 2024
Merged

Conversation

bobleesj
Copy link
Contributor

Closes #269

@id.setter
def id(self, _):
raise AttributeError(_setter_wmsg("id"))
@uuid.setter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

while User still has access to uuid, we make it non-settable still.

Copy link
Contributor Author

@bobleesj bobleesj left a 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

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (8107874) to head (98a3028).
Report is 43 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #271   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files           8        8           
  Lines         379      379           
=======================================
  Hits          374      374           
  Misses          5        5           
Files with missing lines Coverage Δ
tests/test_diffraction_objects.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

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.

just one thought.

@@ -50,7 +50,7 @@ class DiffractionObject:
The array containing the quantity of q, tth, d values.
input_xtype : str
The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES}
id : uuid
_uuid : uuid
Copy link
Contributor

Choose a reason for hiding this comment

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

if we are making this attribute public and giving it a getter, I wonder if we should just call it uuid and remove the underscore? What do you think? It may also be less confusing if the attribute name and how it is accessed is the szme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. It turns out we shall write a separate docstring for @property methods as shown below (as done in the latest commit):

    @property
    def uuid(self):
        """The unique identifier for the DiffractionObject instance.

        Returns
        -------
        uuid
            The unique identifier of the DiffractionObject instance.
        """
        return self._uuid

This way, User does not have to read private properties starting with _.

API doc is also clearly marked with @property:

Screenshot 2024-12-25 at 11 12 35 PM

input_xtype : str
The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES}
id : uuid
The unique identifier for the diffraction object.
Copy link
Contributor Author

@bobleesj bobleesj Dec 26, 2024

Choose a reason for hiding this comment

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

These are marked with @property - docstrings are provided separately (please see below)

@bobleesj
Copy link
Contributor Author

@sbillinge thanks for your review - ready for review, with my reply above: #271 (comment)

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.

few questions inline.

Returns
-------
ndarray
The 2D array containing the `xarray` values in q, tth, d, and `yarray`.
Copy link
Contributor

Choose a reason for hiding this comment

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

for lower cognitive load I would change to The shape(len(data), 4)2D array with columns containing theyarray(intensity) and thexarray values in q, tth, and d . so they appear in the docstring in the same order as in the array columns

Copy link
Contributor Author

@bobleesj bobleesj Dec 26, 2024

Choose a reason for hiding this comment

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

Yes, great! superb. The example and this docstring makes it super clear.


Examples
--------
>>> my_do.all_arrays[:, 0] # yarray
Copy link
Contributor

Choose a reason for hiding this comment

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

add "To access specific arrays individually, use these slices:"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-12-26 at 2 46 56 PM

Yes, great. done

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a stray y-array at the end of the line :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry - fixed now:


        The shape (len(data), 4) 2D array with columns containing the `yarray` (intensity)
        and the `xarray` values in q, tth, and d.

@@ -319,7 +341,8 @@ def get_array_index(self, value, xtype=None):

Returns
-------
the index of the value in the array
list
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 check. Logically, this should return an int not a list. Let's check and maybe update the function/tesnts, or understand why it returns a list and change the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I created a separate issue for this since it's beyond the scope of this PR. I will look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bobleesj
Copy link
Contributor Author

@sbillinge ready for review - addressed your comments. thanks for the review

@bobleesj
Copy link
Contributor Author

@sbillinge ready for review - fixed the extra yarray

@sbillinge sbillinge merged commit b0b6676 into diffpy:main Dec 26, 2024
5 checks passed
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.

Do we want to call the DO unique id as id or uuid?
2 participants