Skip to content

Commit

Permalink
inline computation results in the return statement directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Frix-x committed Nov 23, 2024
1 parent 167bcb3 commit e7f3180
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
5 changes: 1 addition & 4 deletions shaketune/graph_creators/axes_map_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def compute(self):
formatted_direction_vector = self._format_direction_vector(direction_vectors)
ConsoleOutput.print(f'--> Detected axes_map: {formatted_direction_vector}')

# Prepare data for plotting
computation_result = {
return {
'acceleration_data_0': [d[0] for d in acceleration_data],
'acceleration_data_1': [d[1] for d in acceleration_data],
'gravity': gravity,
Expand All @@ -153,8 +152,6 @@ def compute(self):
'st_version': self.st_version,
}

return computation_result

def _wavelet_denoise(self, data: np.ndarray, wavelet: str = 'db1', level: int = 1) -> Tuple[np.ndarray, np.ndarray]:
coeffs = pywt.wavedec(data, wavelet, mode='smooth')
threshold = np.median(np.abs(coeffs[-level])) / 0.6745 * np.sqrt(2 * np.log(len(data)))
Expand Down
5 changes: 1 addition & 4 deletions shaketune/graph_creators/belts_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ def compute(self):
mhi = self._compute_mhi(similarity_factor, signal1, signal2)
ConsoleOutput.print(f'Mechanical health: {mhi}')

# Prepare data for plotting
computation_result = {
return {
'signal1': signal1,
'signal2': signal2,
'similarity_factor': similarity_factor,
Expand All @@ -135,8 +134,6 @@ def compute(self):
'max_freq': self.max_freq,
}

return computation_result

def _compute_signal_data(self, data: np.ndarray, common_freqs: np.ndarray, max_freq: float):
helper = get_shaper_calibrate_module().ShaperCalibrate(printer=None)
calibration_data = helper.process_accelerometer_data(data)
Expand Down
5 changes: 1 addition & 4 deletions shaketune/graph_creators/shaper_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def compute(self):
shaper_choices = [klipper_shaper_choice.upper()]
ConsoleOutput.print(f'{shaper_string} (with a damping ratio of {zeta:.3f})')

# And finally setup the results to return them
computation_result = {
return {
'measurements': self.measurements,
'compat': compat,
'max_smoothing_computed': max_smoothing_computed,
Expand All @@ -221,8 +220,6 @@ def compute(self):
'st_version': self.st_version,
}

return computation_result

# Find the best shaper parameters using Klipper's official algorithm selection with
# a proper precomputed damping ratio (zeta) and using the configured printer SQV value
# This function also sweep around the smoothing values to help you find the best compromise
Expand Down
4 changes: 1 addition & 3 deletions shaketune/graph_creators/static_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def compute(self):
pdata, bins, t = compute_spectrogram(datas[0])
del datas

computation_result = {
return {
'freq': self.freq,
'duration': self.duration,
'accel_per_hz': self.accel_per_hz,
Expand All @@ -89,5 +89,3 @@ def compute(self):
'pdata': pdata,
'max_freq': self.max_freq,
}

return computation_result
4 changes: 1 addition & 3 deletions shaketune/graph_creators/vibrations_graph_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def compute(self):
f'Motors have a main resonant frequency at {motor_fr:.1f}Hz but it was impossible to estimate a damping ratio.'
)

computation_results = {
return {
'measurements': self.measurements,
'all_speeds': all_speeds,
'all_angles': all_angles,
Expand Down Expand Up @@ -241,8 +241,6 @@ def compute(self):
'st_version': self.st_version,
}

return computation_results

# Calculate motor frequency profiles based on the measured Power Spectral Density (PSD) measurements for the machine kinematics
# main angles and then create a global motor profile as a weighted average (from their own vibrations) of all calculated profiles
def _compute_motor_profiles(
Expand Down

0 comments on commit e7f3180

Please sign in to comment.