[varLib.models] Port getMasterScalars tests from Just
https://github.com/fonttools/fonttools/pull/3380#issuecomment-1846051270
This commit is contained in:
parent
ae69c22df8
commit
0edb0072f3
@ -192,6 +192,17 @@ def test_modeling_error(numLocations, numSamples):
|
||||
# print("{:d} {:.2} {:.2}".format(i, err, err_bad))
|
||||
|
||||
|
||||
locationsA = [{}, {"wght": 1}, {"wdth": 1}]
|
||||
locationsB = [{}, {"wght": 1}, {"wdth": 1}, {"wght": 1, "wdth": 1}]
|
||||
locationsC = [
|
||||
{},
|
||||
{"wght": 0.5},
|
||||
{"wght": 1},
|
||||
{"wdth": 1},
|
||||
{"wght": 1, "wdth": 1},
|
||||
]
|
||||
|
||||
|
||||
class VariationModelTest(object):
|
||||
@pytest.mark.parametrize(
|
||||
"locations, axisOrder, sortedLocs, supports, deltaWeights",
|
||||
@ -441,3 +452,81 @@ class VariationModelTest(object):
|
||||
assert interpolatedValue == expectedValue
|
||||
|
||||
assert masterScalars == model.getMasterScalars(instanceLocation)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"masterLocations, location, expected",
|
||||
[
|
||||
(locationsA, {"wght": 0, "wdth": 0}, [1, 0, 0]),
|
||||
(
|
||||
locationsA,
|
||||
{"wght": 0.5, "wdth": 0},
|
||||
[0.5, 0.5, 0],
|
||||
),
|
||||
(locationsA, {"wght": 1, "wdth": 0}, [0, 1, 0]),
|
||||
(
|
||||
locationsA,
|
||||
{"wght": 0, "wdth": 0.5},
|
||||
[0.5, 0, 0.5],
|
||||
),
|
||||
(locationsA, {"wght": 0, "wdth": 1}, [0, 0, 1]),
|
||||
(locationsA, {"wght": 1, "wdth": 1}, [-1, 1, 1]),
|
||||
(
|
||||
locationsA,
|
||||
{"wght": 0.5, "wdth": 0.5},
|
||||
[0, 0.5, 0.5],
|
||||
),
|
||||
(
|
||||
locationsA,
|
||||
{"wght": 0.75, "wdth": 0.75},
|
||||
[-0.5, 0.75, 0.75],
|
||||
),
|
||||
(
|
||||
locationsB,
|
||||
{"wght": 1, "wdth": 1},
|
||||
[0, 0, 0, 1],
|
||||
),
|
||||
(
|
||||
locationsB,
|
||||
{"wght": 0.5, "wdth": 0},
|
||||
[0.5, 0.5, 0, 0],
|
||||
),
|
||||
(
|
||||
locationsB,
|
||||
{"wght": 1, "wdth": 0.5},
|
||||
[0, 0.5, 0, 0.5],
|
||||
),
|
||||
(
|
||||
locationsB,
|
||||
{"wght": 0.5, "wdth": 0.5},
|
||||
[0.25, 0.25, 0.25, 0.25],
|
||||
),
|
||||
(
|
||||
locationsC,
|
||||
{"wght": 0.5, "wdth": 0},
|
||||
[0, 1, 0, 0, 0],
|
||||
),
|
||||
(
|
||||
locationsC,
|
||||
{"wght": 0.25, "wdth": 0},
|
||||
[0.5, 0.5, 0, 0, 0],
|
||||
),
|
||||
(
|
||||
locationsC,
|
||||
{"wght": 0.75, "wdth": 0},
|
||||
[0, 0.5, 0.5, 0, 0],
|
||||
),
|
||||
(
|
||||
locationsC,
|
||||
{"wght": 0.5, "wdth": 1},
|
||||
[-0.5, 1, -0.5, 0.5, 0.5],
|
||||
),
|
||||
(
|
||||
locationsC,
|
||||
{"wght": 0.75, "wdth": 1},
|
||||
[-0.25, 0.5, -0.25, 0.25, 0.75],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_getMasterLocations(self, masterLocations, location, expected):
|
||||
model = VariationModel(masterLocations)
|
||||
assert model.getMasterScalars(location) == expected
|
||||
|
Loading…
x
Reference in New Issue
Block a user