bed_mesh: Improve Python3 compatibility

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-06-12 10:03:57 -04:00
parent 0ccf3018d5
commit 8c96e9dd11
1 changed files with 6 additions and 6 deletions

View File

@ -390,7 +390,7 @@ class BedMeshCalibrate:
for line in z_values if line.strip()] for line in z_values if line.strip()]
self.profiles[name]['mesh_params'] = params = \ self.profiles[name]['mesh_params'] = params = \
collections.OrderedDict() collections.OrderedDict()
for key, t in PROFILE_OPTIONS.iteritems(): for key, t in PROFILE_OPTIONS.items():
if t is int: if t is int:
params[key] = profile.getint(key) params[key] = profile.getint(key)
elif t is float: elif t is float:
@ -414,7 +414,7 @@ class BedMeshCalibrate:
z_values = z_values[:-2] z_values = z_values[:-2]
configfile.set(cfg_name, 'version', PROFILE_VERSION) configfile.set(cfg_name, 'version', PROFILE_VERSION)
configfile.set(cfg_name, 'points', z_values) configfile.set(cfg_name, 'points', z_values)
for key, value in self.mesh_params.iteritems(): for key, value in self.mesh_params.items():
configfile.set(cfg_name, key, value) configfile.set(cfg_name, key, value)
# save copy in local storage # save copy in local storage
self.profiles[prof_name] = profile = {} self.profiles[prof_name] = profile = {}
@ -532,7 +532,7 @@ class BedMeshCalibrate:
msg += "Probed Table:\n" msg += "Probed Table:\n"
msg += str(self.probed_matrix) msg += str(self.probed_matrix)
raise self.gcode.error(msg) raise self.gcode.error(msg)
buf_cnt = (x_cnt - row_size) / 2 buf_cnt = (x_cnt - row_size) // 2
if buf_cnt == 0: if buf_cnt == 0:
continue continue
left_buffer = [row[0]] * buf_cnt left_buffer = [row[0]] * buf_cnt
@ -626,7 +626,7 @@ class ZMesh:
self.avg_z = 0. self.avg_z = 0.
self.mesh_offset = 0. self.mesh_offset = 0.
logging.debug('bed_mesh: probe/mesh parameters:') logging.debug('bed_mesh: probe/mesh parameters:')
for key, value in self.mesh_params.iteritems(): for key, value in self.mesh_params.items():
logging.debug("%s : %s" % (key, value)) logging.debug("%s : %s" % (key, value))
self.mesh_x_min = params['min_x'] self.mesh_x_min = params['min_x']
self.mesh_x_max = params['max_x'] self.mesh_x_max = params['max_x']
@ -738,7 +738,7 @@ class ZMesh:
y_mult = self.y_mult y_mult = self.y_mult
self.mesh_matrix = \ self.mesh_matrix = \
[[0. if ((i % x_mult) or (j % y_mult)) [[0. if ((i % x_mult) or (j % y_mult))
else z_matrix[j/y_mult][i/x_mult] else z_matrix[j//y_mult][i//x_mult]
for i in range(self.mesh_x_count)] for i in range(self.mesh_x_count)]
for j in range(self.mesh_y_count)] for j in range(self.mesh_y_count)]
xpts, ypts = self._get_lagrange_coords() xpts, ypts = self._get_lagrange_coords()
@ -793,7 +793,7 @@ class ZMesh:
c = self.mesh_params['tension'] c = self.mesh_params['tension']
self.mesh_matrix = \ self.mesh_matrix = \
[[0. if ((i % x_mult) or (j % y_mult)) [[0. if ((i % x_mult) or (j % y_mult))
else z_matrix[j/y_mult][i/x_mult] else z_matrix[j//y_mult][i//x_mult]
for i in range(self.mesh_x_count)] for i in range(self.mesh_x_count)]
for j in range(self.mesh_y_count)] for j in range(self.mesh_y_count)]
# Interpolate X values # Interpolate X values