Skip to content

Remove set_angles_from_list, set_angles_from, set_qs_from_range #233

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 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/rm-range-methods.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* `set_angles_from_list`, `set_angles_from`, `set_qs_from_range` methods in `DiffractionObject`

**Fixed:**

* <news item>

**Security:**

* <news item>
67 changes: 0 additions & 67 deletions src/diffpy/utils/diffraction_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,73 +215,6 @@ def id(self):
def id(self, _):
raise AttributeError(_setter_wmsg("id"))

def set_angles_from_list(self, angles_list):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the following methods, I've double checked that no tests associated were found and pytest runs locally without these.

self.angles = angles_list
self.n_steps = len(angles_list) - 1.0
self.begin_angle = self.angles[0]
self.end_angle = self.angles[-1]

def set_qs_from_range(self, begin_q, end_q, step_size=None, n_steps=None):
"""
create an array of linear spaced Q-values

Parameters
----------
begin_q float
the beginning angle
end_q float
the ending angle
step_size float
the size of the step between points. Only specify step_size or n_steps, not both
n_steps integer
the number of steps. Odd numbers are preferred. Only specify step_size or n_steps, not both

Returns
-------
Sets self.qs
self.qs array of floats
the q values in the independent array

"""
self.qs = self._set_array_from_range(begin_q, end_q, step_size=step_size, n_steps=n_steps)

def set_angles_from_range(self, begin_angle, end_angle, step_size=None, n_steps=None):
"""
create an array of linear spaced angle-values

Parameters
----------
begin_angle float
the beginning angle
end_angle float
the ending angle
step_size float
the size of the step between points. Only specify step_size or n_steps, not both
n_steps integer
the number of steps. Odd numbers are preferred. Only specify step_size or n_steps, not both

Returns
-------
Sets self.angles
self.angles array of floats
the q values in the independent array

"""
self.angles = self._set_array_from_range(begin_angle, end_angle, step_size=step_size, n_steps=n_steps)

def _set_array_from_range(self, begin, end, step_size=None, n_steps=None):
if step_size is not None and n_steps is not None:
print(
"WARNING: both step_size and n_steps have been given. n_steps will be used and step_size will be "
"reset."
)
array = np.linspace(begin, end, n_steps)
elif step_size is not None:
array = np.arange(begin, end, step_size)
elif n_steps is not None:
array = np.linspace(begin, end, n_steps)
return array

def get_array_index(self, value, xtype=None):
"""
Return the index of the closest value in the array associated with the specified xtype.
Expand Down
Loading