-
Notifications
You must be signed in to change notification settings - Fork 21
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
Moved resample out of parsers to its own sub-package #158
Closed
+62
−46
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d6b1b8
moved resample out of parsers
6a121cc
added back parsers __init__.py to be able to import the functions
79a2f1e
renamed functions and files to PEP8
87a5b6d
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] 2c364fc
fixed diffraction_objects class name
f45ba82
Merge branch 'resample-relocation' of https://github.com/alisnwu/diff…
5f285e0
updated news item
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
) | ||
|
||
|
||
class Diffraction_object: | ||
class diffraction_object: | ||
def __init__(self, name="", wavelength=None): | ||
self.name = name | ||
self.wavelength = wavelength | ||
|
@@ -29,7 +29,7 @@ def __init__(self, name="", wavelength=None): | |
self.metadata = {} | ||
|
||
def __eq__(self, other): | ||
if not isinstance(other, Diffraction_object): | ||
if not isinstance(other, diffraction_object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also - if it's camelcased, then it improves readability in lines like here |
||
return NotImplemented | ||
self_attributes = [key for key in self.__dict__ if not key.startswith("_")] | ||
other_attributes = [key for key in other.__dict__ if not key.startswith("_")] | ||
|
@@ -59,7 +59,7 @@ def __add__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
summed.on_tth[1] = self.on_tth[1] + other | ||
summed.on_q[1] = self.on_q[1] + other | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to sum two Diffraction_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
@@ -73,7 +73,7 @@ def __radd__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
summed.on_tth[1] = self.on_tth[1] + other | ||
summed.on_q[1] = self.on_q[1] + other | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to sum two Scattering_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
@@ -87,7 +87,7 @@ def __sub__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
subtracted.on_tth[1] = self.on_tth[1] - other | ||
subtracted.on_q[1] = self.on_q[1] - other | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to subtract two Scattering_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
@@ -101,7 +101,7 @@ def __rsub__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
subtracted.on_tth[1] = other - self.on_tth[1] | ||
subtracted.on_q[1] = other - self.on_q[1] | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to subtract two Scattering_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
@@ -115,7 +115,7 @@ def __mul__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
multiplied.on_tth[1] = other * self.on_tth[1] | ||
multiplied.on_q[1] = other * self.on_q[1] | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to multiply two Scattering_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
@@ -141,7 +141,7 @@ def __truediv__(self, other): | |
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): | ||
divided.on_tth[1] = other / self.on_tth[1] | ||
divided.on_q[1] = other / self.on_q[1] | ||
elif not isinstance(other, Diffraction_object): | ||
elif not isinstance(other, diffraction_object): | ||
raise TypeError("I only know how to multiply two Scattering_object objects") | ||
elif self.on_tth[0].all() != other.on_tth[0].all(): | ||
raise RuntimeError(x_grid_emsg) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Although this wasn't discussed before, could we try
CamelCase
?https://peps.python.org/pep-0008/#class-names
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.
Actually, not camel case which is not the PEP8 standard, but Classes always begin with capital letters. Please everyone read the PEP8 standards....
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.
Seems it's got two interpretations:
while PEP8 says,
but yeah I guess
CapWords
works..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.
yeah I will add this to our gitlab so that we can say, "did you read that section" or "refer to here.."