Skip to content

Commit b63ab7a

Browse files
authored
Merge branch 'master' into 46-manipulations-dot-py-rewrite
2 parents d328eef + 650d9b5 commit b63ab7a

4 files changed

Lines changed: 147 additions & 5 deletions

File tree

.codescene/code-health-rules.json

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"rule_sets" : [ {
3+
"thresholds" : [ {
4+
"name" : "constructor_max_arguments",
5+
"value" : "7"
6+
}, {
7+
"name" : "file_lines_of_code_for_alert",
8+
"value" : "5000"
9+
}, {
10+
"name" : "file_lines_of_code_for_critical_alert",
11+
"value" : "2500"
12+
}, {
13+
"name" : "file_lines_of_code_for_warning",
14+
"value" : "1000"
15+
}, {
16+
"name" : "file_mean_cyclomatic_complexity_warning",
17+
"value" : "8"
18+
}, {
19+
"name" : "function_bumpy_road_bumps_for_warning",
20+
"value" : "8"
21+
}, {
22+
"name" : "function_bumpy_road_nesting_level_depth",
23+
"value" : "25"
24+
}, {
25+
"name" : "function_complex_conditional_branches_alert",
26+
"value" : "25"
27+
}, {
28+
"name" : "function_complex_conditional_branches_warning",
29+
"value" : "10"
30+
}, {
31+
"name" : "function_cyclomatic_complexity_alert",
32+
"value" : "25"
33+
}, {
34+
"name" : "function_cyclomatic_complexity_warning",
35+
"value" : "5"
36+
}, {
37+
"name" : "function_lines_of_code_alert",
38+
"value" : "2500"
39+
}, {
40+
"name" : "function_lines_of_code_warning",
41+
"value" : "1000"
42+
}, {
43+
"name" : "function_max_arguments",
44+
"value" : "7"
45+
}, {
46+
"name" : "function_nesting_depth_warning",
47+
"value" : "10"
48+
}
49+
],
50+
"matching_content_path" : "**/*",
51+
"matching_content_path_doc" : "**/*",
52+
"rules" : [ {
53+
"name" : "Brain Method",
54+
"weight" : 0.0
55+
}, {
56+
"name" : "Bumpy Road Ahead",
57+
"weight" : 0.0
58+
}, {
59+
"name" : "Code Duplication",
60+
"weight" : 0.0
61+
}, {
62+
"name" : "Complex Conditional",
63+
"weight" : 0.0
64+
}, {
65+
"name" : "Complex Method",
66+
"weight" : 0.0
67+
}, {
68+
"name" : "Constructor Over-Injection",
69+
"weight" : 0.0
70+
}, {
71+
"name" : "Deep, Global Nested Complexity",
72+
"weight" : 0.0
73+
}, {
74+
"name" : "Deep, Nested Complexity",
75+
"weight" : 0.0
76+
}, {
77+
"name" : "Duplicated Assertion Blocks",
78+
"weight" : 0.0
79+
}, {
80+
"name" : "Excess Number of Function Arguments",
81+
"weight" : 0.0
82+
}, {
83+
"name" : "Global Conditionals",
84+
"weight" : 0.0
85+
}, {
86+
"name" : "Large Assertion Blocks",
87+
"weight" : 0.0
88+
}, {
89+
"name" : "Large Embedded Code Block",
90+
"weight" : 0.0
91+
}, {
92+
"name" : "Large Method",
93+
"weight" : 0.0
94+
}, {
95+
"name" : "Lines of Code in a Single File",
96+
"weight" : 0.0
97+
}, {
98+
"name" : "Lines of Declarations in a Single File",
99+
"weight" : 0.0
100+
}, {
101+
"name" : "Low Cohesion",
102+
"weight" : 0.0
103+
}, {
104+
"name" : "Missing Arguments Abstractions",
105+
"weight" : 0.0
106+
}, {
107+
"name" : "Number of Functions in a Single Module",
108+
"weight" : 0.0
109+
}, {
110+
"name" : "Overall Code Complexity",
111+
"weight" : 0.0
112+
}, {
113+
"name" : "Overall Function Size",
114+
"weight" : 0.0
115+
}, {
116+
"name" : "Primitive Obsession",
117+
"weight" : 0.0
118+
}, {
119+
"name" : "String Heavy Function Arguments",
120+
"weight" : 0.0
121+
} ]
122+
} ]
123+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"rule_sets": [
3+
{
4+
"quality_gates": {
5+
"hotspot_decline": true,
6+
"critical_health_rules": true,
7+
"refactoring_goals": false,
8+
"supervise_goals": false,
9+
"new_code_health": true,
10+
"advisory_health_rules": true,
11+
"codeowners_for_critical_code": false
12+
}
13+
}
14+
]
15+
}

sasdata/data_util/manipulations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def position_and_wavelength_to_q(dx: float, dy: float, detector_distance: float,
8888
plane_dist = math.sqrt(dx * dx + dy * dy)
8989
# Half of the scattering angle
9090
theta = 0.5 * math.atan(plane_dist / detector_distance)
91-
return (4.0 * math.pi / wavelength) * math.sin(theta)
91+
return (2.0* TwoPi / wavelength) * math.sin(theta)
9292

9393

9494
def get_q_compo(dx: float, dy: float, detector_distance: float, wavelength: float, compo: str | None = None) -> float:
@@ -100,7 +100,7 @@ def get_q_compo(dx: float, dy: float, detector_distance: float, wavelength: floa
100100
if dx >= 0:
101101
angle_xy = 0
102102
else:
103-
angle_xy = math.pi
103+
angle_xy = Pi
104104
else:
105105
angle_xy = math.atan(dx / dy)
106106

@@ -121,9 +121,9 @@ def flip_phi(phi: float) -> float:
121121
:return: phi in >=0 and <=2Pi
122122
"""
123123
if phi < 0:
124-
phi_out = phi + (2 * math.pi)
125-
elif phi > (2 * math.pi):
126-
phi_out = phi - (2 * math.pi)
124+
phi_out = phi + (TwoPi)
125+
elif phi > (TwoPi):
126+
phi_out = phi % TwoPi
127127
else:
128128
phi_out = phi
129129
return phi_out

sasdata/quantities/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import math
2+
3+
Pi = math.pi
4+
TwoPi = 2 * math.pi

0 commit comments

Comments
 (0)