Skip to content
Open
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
6 changes: 2 additions & 4 deletions pydnmr/dnmrmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ def two_spin(v, va, vb, ka, wa, wb, pa):
R = 2 * pi * Dv * (1 + tau * ((1 / T2a) + (1 / T2b)))
R += pi * dv * tau * ((1 / T2b) - (1 / T2a)) + pi * dv * (pa - pb)

I = (P * (1 + tau * ((pb / T2a) + (pa / T2b))) + Q * R) / (P ** 2 + R ** 2)
return I
return (P * (1 + tau * ((pb / T2a) + (pa / T2b))) + Q * R) / (P ** 2 + R ** 2)
Copy link
Author

Choose a reason for hiding this comment

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

Function two_spin refactored with the following changes:

  • Inline variable that is only used once



def d2s_func(va, vb, ka, wa, wb, pa):
Expand Down Expand Up @@ -241,5 +240,4 @@ def dnmr_AB(v, v1, v2, J, k, w):
n2 = r_minus * b_minus - s * a_minus
d2 = a_minus ** 2 + b_minus ** 2

I = (n1 / d1) + (n2 / d2)
return I
return (n1 / d1) + (n2 / d2)
Comment on lines -244 to +243
Copy link
Author

Choose a reason for hiding this comment

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

Function dnmr_AB refactored with the following changes:

  • Inline variable that is only used once

15 changes: 6 additions & 9 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,13 @@ def test_find_two_singlets_widget(self):
def test_find_two_singlets_layout(self):

foundLayout = self.ui.findChild(QGridLayout, 'twosingletslayout')
if foundLayout:
print('Found layout named', foundLayout.objectName())
print('Found layout has parent:', foundLayout.parent(),
foundLayout.parent().objectName())
else:
if not foundLayout:
foundLayout = self.ui.centralWidget().layout()
print('Did not find QGridLayout child named "twosingletlayout"')
print('Found layout named', foundLayout.objectName())
print('Found layout has parent:', foundLayout.parent(),
foundLayout.parent().objectName())

print('Found layout named', foundLayout.objectName())
print('Found layout has parent:', foundLayout.parent(),
foundLayout.parent().objectName())
Comment on lines -150 to +156
Copy link
Author

Choose a reason for hiding this comment

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

Function TestDefaultGUi.test_find_two_singlets_layout refactored with the following changes:

  • Hoist repeated code outside conditional statement
  • Swap if/else to remove empty if body


def test_find_AB_widget(self):
foundABWidget = self.ui.findChild(QWidget, 'abwidget')
Expand Down Expand Up @@ -361,7 +358,7 @@ def test_twiddle_buttons(self):

for widget in main.ab_vars:
print(widget.value, 'vs. ', self.widgetdict[widget.key].value())
if widget.key == 'k_ab' or widget.key == 'wa':
if widget.key in ['k_ab', 'wa']:
Comment on lines -364 to +361
Copy link
Author

Choose a reason for hiding this comment

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

Function TestABGUi.test_twiddle_buttons refactored with the following changes:

  • Replace multiple comparisons of same variable with in operator

assert self.widgetdict[widget.key].value() == 20.01
# k and wa widgets should not go below 0.01
elif widget.key == 'j_ab':
Expand Down