Skip to content
Snippets Groups Projects
Commit 8876bf45 authored by Felix Metzner's avatar Felix Metzner
Browse files

Some formatting in scale_cut and addition of a new assertion.

parent e429cc48
Branches
No related tags found
2 merge requests!63Low level cut study,!62Cut info reworking
......@@ -156,28 +156,32 @@ class CutInfo:
return [str(float(f))]
def scale_cut(self, percentage: float = 0.1) -> "CutInfo":
assert 0. <= percentage < 1., percentage
if self.cut_type == "==":
cut_str = ""
cut_type = ""
cut_limits = 0
elif self.cut_type in ["<", "<="]:
temp_cut_limits = self.cut_limits
self.__cut_limits = (1 + percentage) * self.cut_limits if self.cut_limits > 0 else (1 - percentage) * self.cut_limits
scale_factor = (1. + percentage) if self.cut_limits > 0. else (1. - percentage)
self.__cut_limits = scale_factor * self.cut_limits
cut_str = self.generate_cut_str()[0]
cut_type = self.cut_type
cut_limits = self.cut_limits
self.__cut_limits = temp_cut_limits
elif self.cut_type in [">", ">="]:
temp_cut_limits = self.cut_limits
self.__cut_limits = (1 - percentage) * self.cut_limits if self.cut_limits > 0 else (1 + percentage) * self.cut_limits
scale_factor = (1. - percentage) if self.cut_limits > 0. else (1. + percentage)
self.__cut_limits = scale_factor * self.cut_limits
cut_str = self.generate_cut_str()[0]
cut_type = self.cut_type
cut_limits = self.cut_limits
self.__cut_limits = temp_cut_limits
else:
temp_cut_limits = self.cut_limits
self.__cut_limits = ((1 - percentage) * self.cut_limits[0] if self.cut_limits[0] > 0 else (1 + percentage) * self.cut_limits[0],
(1 + percentage) * self.cut_limits[1] if self.cut_limits[1] > 0 else (1 - percentage) * self.cut_limits[1])
left_scale_factor = (1. - percentage) if self.cut_limits[0] > 0. else (1. + percentage)
right_scale_factor = (1. + percentage) if self.cut_limits[1] > 0. else (1. - percentage)
self.__cut_limits = (left_scale_factor * self.cut_limits[0], right_scale_factor * self.cut_limits[1])
cut_str = self.generate_cut_str()[0]
cut_type = self.cut_type
cut_limits = self.cut_limits
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment