-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Describe the bug
the minimum window width is imposed after the global bounds trim rather than before which I think means that if a minimum window is wide enough then it can escape global bounds. This applies to the trim method of the SequentialDomainReductionTransformer.
To Reproduce
For example:
def _trim(new_bounds: np.array, global_bounds: np.array) -> np.array:
min_window = 1
for i, variable in enumerate(new_bounds):
if variable[0] < global_bounds[i, 0]:
variable[0] = global_bounds[i, 0]
if variable[1] > global_bounds[i, 1]:
variable[1] = global_bounds[i, 1]
for i, entry in enumerate(new_bounds):
if entry[0] > entry[1]:
new_bounds[i, 0] = entry[1]
new_bounds[i, 1] = entry[0]
window_width = abs(entry[0] - entry[1])
if window_width < 1:
new_bounds[i, 0] -= (min_window - window_width) / 2.0
new_bounds[i, 1] += (min_window - window_width) / 2.0
return new_bounds
new_bounds = np.concatenate((np.ones((5,1))*0.1,np.ones((5,1))),axis=1)
global_bounds = np.concatenate((np.ones((5,1))*-1,np.ones((5,1))),axis=1)*0.5
print(new_bounds)
print(global_bounds)
print(_trim(new_bounds,global_bounds))
prints:
[[0.1 1. ]
[0.1 1. ]
[0.1 1. ]
[0.1 1. ]
[0.1 1. ]]
[[-0.5 0.5]
[-0.5 0.5]
[-0.5 0.5]
[-0.5 0.5]
[-0.5 0.5]]
[[-0.2 0.8]
[-0.2 0.8]
[-0.2 0.8]
[-0.2 0.8]
[-0.2 0.8]]where the first array is new_bounds before trim, second is global bounds and third is the trimmed version which is outside global bounds
Expected behavior
I think the global bounds check and minimum window should be combined in a way to respect both, e.g. for the example above it should return the new_bounds as -0.5 and 0.5.
Screenshots
bwheelz36