[instancer.solver] Return None as gain tent

This commit is contained in:
Behdad Esfahbod 2022-08-08 10:46:55 -06:00
parent a87ba55a90
commit c3fa1b59ac
3 changed files with 13 additions and 13 deletions

View File

@ -248,7 +248,7 @@ def changeTupleVariationAxisLimit(var, axisTag, axisLimit):
out = [] out = []
for scalar,tent in solutions: for scalar,tent in solutions:
newVar = TupleVariation(var.axes, var.coordinates) if len(solutions) > 1 else var newVar = TupleVariation(var.axes, var.coordinates) if len(solutions) > 1 else var
if tent[1] == 0: if tent is None:
newVar.axes.pop(axisTag) newVar.axes.pop(axisTag)
else: else:
newVar.axes[axisTag] = tent newVar.axes[axisTag] = tent

View File

@ -47,7 +47,7 @@ def _solveWithGain(tent, axisLimit):
# lower <= axisDef <= peak <= axisMax # lower <= axisDef <= peak <= axisMax
gain = supportScalar({'tag': axisDef}, {'tag': tent}) gain = supportScalar({'tag': axisDef}, {'tag': tent})
out = [(gain, axisLimit)] out = [(gain, None)]
# First, the positive side # First, the positive side
@ -137,7 +137,7 @@ def _solveGeneral(tent, axisLimit):
# Mirror the problem such that axisDef is always <= peak # Mirror the problem such that axisDef is always <= peak
if axisDef > peak: if axisDef > peak:
return [(scalar, _revnegate(t)) return [(scalar, _revnegate(t) if t is not None else None)
for scalar,t for scalar,t
in _solveGeneral(_revnegate(tent), in _solveGeneral(_revnegate(tent),
_revnegate(axisLimit))] _revnegate(axisLimit))]
@ -179,5 +179,5 @@ def rebaseTent(tent, axisLimit):
sols = _solveGeneral(tent, axisLimit) sols = _solveGeneral(tent, axisLimit)
n = lambda v: normalizeValue(v, axisLimit, extrapolate=True) n = lambda v: normalizeValue(v, axisLimit, extrapolate=True)
sols = [(scalar, (n(v[0]), n(v[1]), n(v[2]))) for scalar,v in sols if scalar != 0] sols = [(scalar, (n(v[0]), n(v[1]), n(v[2])) if v is not None else None) for scalar,v in sols if scalar != 0]
return sols return sols

View File

@ -25,7 +25,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(0, 1, 1), (.5, .5, .5), (0, 1, 1), (.5, .5, .5),
[ [
(.5, (0, 0, 0)), (.5, None),
] ]
), ),
@ -88,7 +88,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.0, .5, 1), (0, .5, 1), (.0, .5, 1), (0, .5, 1),
[ [
(1, (-1, 0, 1)), (1, None),
(-1, (0, 1, 1)), (-1, (0, 1, 1)),
(-1, (-1, -1, 0)), (-1, (-1, -1, 0)),
] ]
@ -98,7 +98,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.0, .5, 2), (.2, .5, .8), (.0, .5, 2), (.2, .5, .8),
[ [
(1, (-1, 0, 1)), (1, None),
(-0.20000000000000007, (0, 1, 1)), (-0.20000000000000007, (0, 1, 1)),
(-.6, (-1, -1, 0)), (-.6, (-1, -1, 0)),
] ]
@ -108,7 +108,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.0, .5, 2), (.2, .5, 1), (.0, .5, 2), (.2, .5, 1),
[ [
(1, (-1, 0, 1)), (1, None),
(-0.33333333333333337, (0, 1, 1)), (-0.33333333333333337, (0, 1, 1)),
(-.6, (-1, -1, 0)), (-.6, (-1, -1, 0)),
] ]
@ -118,7 +118,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.0, .5, 1), (0, .25, .5), (.0, .5, 1), (0, .25, .5),
[ [
(.5, (-1, 0, 1)), (.5, None),
(.5, (0, 1, 1)), (.5, (0, 1, 1)),
(-.5, (-1, -1, 0)), (-.5, (-1, -1, 0)),
] ]
@ -128,7 +128,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.05, .55, 1), (0, .25, .5), (.05, .55, 1), (0, .25, .5),
[ [
(.4, (-1.0, 0.0, 1.0)), (.4, None),
(.5, (0, 1, 1)), (.5, (0, 1, 1)),
(-.4, (-1, -.8, 0)), (-.4, (-1, -.8, 0)),
(-.4, (-1, -1, -.8)), (-.4, (-1, -1, -.8)),
@ -139,7 +139,7 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(-1, -.55, -.05), (-.5, -.25, 0), (-1, -.55, -.05), (-.5, -.25, 0),
[ [
(.4, (-1.0, 0.0, 1.0)), (.4, None),
(.5, (-1, -1, 0)), (.5, (-1, -1, 0)),
(-.4, (0, .8, 1)), (-.4, (0, .8, 1)),
(-.4, (.8, 1, 1)), (-.4, (.8, 1, 1)),
@ -153,14 +153,14 @@ class RebaseTentTest(object):
pytest.param( pytest.param(
(.5, .5, .5), (.5, .5, .5), (.5, .5, .5), (.5, .5, .5),
[ [
(1, (0, 0, 0)), (1, None),
] ]
), ),
pytest.param( pytest.param(
(.3, .5, .7), (.1, .5, .9), (.3, .5, .7), (.1, .5, .9),
[ [
(1, (-1, 0, 1)), (1, None),
(-1, (0, 0.4999999999999999, 1)), (-1, (0, 0.4999999999999999, 1)),
(-1, (0.4999999999999999, 1, 1)), (-1, (0.4999999999999999, 1, 1)),
(-1, (-1, -.5, 0)), (-1, (-1, -.5, 0)),