fixed items from code review
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Common functions for the Shake&Tune package
|
||||
# Written by Frix_x#0161 #
|
||||
|
||||
@@ -35,9 +33,9 @@ def parse_log(logname):
|
||||
# Check for a PSD file generated by Klipper and raise a warning
|
||||
if cleaned_line.startswith('#freq,psd_x,psd_y,psd_z,psd_xyz'):
|
||||
ConsoleOutput.print(
|
||||
'Warning: %s does not contain raw accelerometer data. '
|
||||
f'Warning: {logname} does not contain raw accelerometer data. '
|
||||
'Please use the official Klipper script to process it instead. '
|
||||
'It will be ignored by Shake&Tune!' % (logname,)
|
||||
'It will be ignored by Shake&Tune!'
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -48,8 +46,8 @@ def parse_log(logname):
|
||||
|
||||
if not header:
|
||||
ConsoleOutput.print(
|
||||
'Warning: file %s has an incorrect header and will be ignored by Shake&Tune!\n'
|
||||
"Expected '#time,accel_x,accel_y,accel_z', but got '%s'." % (logname, header.strip())
|
||||
f'Warning: file {logname} has an incorrect header and will be ignored by Shake&Tune!\n'
|
||||
f"Expected '#time,accel_x,accel_y,accel_z', but got '{header.strip()}'."
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -57,8 +55,8 @@ def parse_log(logname):
|
||||
data = np.loadtxt(logname, comments='#', delimiter=',', skiprows=1)
|
||||
if data.ndim == 1 or data.shape[1] != 4:
|
||||
ConsoleOutput.print(
|
||||
'Warning: %s does not have the correct data format; expected 4 columns. '
|
||||
'It will be ignored by Shake&Tune!' % (logname,)
|
||||
f'Warning: {logname} does not have the correct data format; expected 4 columns. '
|
||||
'It will be ignored by Shake&Tune!'
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Classes to retrieve a couple of motors infos and extract the relevant information
|
||||
# from the Klipper configuration and the TMC registers
|
||||
# Written by Frix_x#0161 #
|
||||
@@ -41,7 +39,7 @@ class Motor:
|
||||
value_dict = new_value_dict
|
||||
|
||||
# Then gets merged all the thresholds into the same THRS virtual register
|
||||
if register in ['TPWMTHRS', 'TCOOLTHRS']:
|
||||
if register in {'TPWMTHRS', 'TCOOLTHRS'}:
|
||||
existing_thrs = self._registers.get('THRS', {})
|
||||
merged_values = {**existing_thrs, **value_dict}
|
||||
self._registers['THRS'] = merged_values
|
||||
@@ -97,10 +95,7 @@ class Motor:
|
||||
if not differences['registers']:
|
||||
del differences['registers']
|
||||
|
||||
if not differences:
|
||||
return None
|
||||
|
||||
return differences
|
||||
return None if not differences else differences
|
||||
|
||||
|
||||
class MotorsConfigParser:
|
||||
@@ -180,10 +175,7 @@ class MotorsConfigParser:
|
||||
|
||||
# Find and return the motor by its name
|
||||
def get_motor(self, motor_name: str) -> Optional[Motor]:
|
||||
for motor in self._motors:
|
||||
if motor.name == motor_name:
|
||||
return motor
|
||||
return None
|
||||
return next((motor for motor in self._motors if motor.name == motor_name), None)
|
||||
|
||||
# Get all the motor list at once
|
||||
def get_motors(self) -> List[Motor]:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# The logic in this file was "extracted" from Klipper's orignal resonance_tester.py file
|
||||
# Courtesy of Dmitry Butyugin <dmbutyugin@google.com> for the original implementation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user