VariationModel: don't use mutable list default value for 'axisOrder' parameter

This commit is contained in:
Cosimo Lupo 2019-03-04 10:58:47 -08:00
parent 288b7e9f28
commit 389cf7c56a

View File

@ -189,19 +189,19 @@ class VariationModel(object):
7: 0.6666666666666667}]
"""
def __init__(self, locations, axisOrder=[]):
def __init__(self, locations, axisOrder=None):
self.origLocations = locations
self.axisOrder = axisOrder
self.axisOrder = axisOrder if axisOrder else []
locations = [{k:v for k,v in loc.items() if v != 0.} for loc in locations]
keyFunc = self.getMasterLocationsSortKeyFunc(locations, axisOrder=axisOrder)
keyFunc = self.getMasterLocationsSortKeyFunc(locations, axisOrder=self.axisOrder)
axisPoints = keyFunc.axisPoints
self.locations = sorted(locations, key=keyFunc)
# TODO Assert that locations are unique.
self.mapping = [self.locations.index(l) for l in locations] # Mapping from user's master order to our master order
self.reverseMapping = [locations.index(l) for l in self.locations] # Reverse of above
self._computeMasterSupports(axisPoints, axisOrder)
self._computeMasterSupports(axisPoints, self.axisOrder)
self._subModels = {}
def getSubModel(self, items):