#NEWLINE# def _testBiasFromLocations( bias , locs ) : #NEWLINE# #INDENT# ' \n            # Find the designspace vector for the best bias.\n            # Test results: (<number of on-axis locations>, <number of off-axis locations>)\n\n            >>> locs = [Location(a=10), Location(a=10, b=10, c=10), Location(a=10, c=15), Location(a=5, c=15)]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location a:10, c:15 >\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 1)\n            \n            >>> locs = [Location(a=10, b=0), Location(a=5, b=10), Location(a=20, b=0)]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location a:10, b:0 >\n            >>> _testBiasFromLocations(bias, locs)\n            (1, 1)\n            \n            >>> locs = [Location(a=10, b=300), Location(a=20, b=300), Location(a=20, b=600), Location(a=30, b=300)]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location a:20, b:300 >\n            >>> _testBiasFromLocations(bias, locs)\n            (3, 0)\n            \n            >>> locs = [Location(a=-10, b=300), Location(a=0, b=400), Location(a=20, b=300)]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location a:-10, b:300 >\n            >>> _testBiasFromLocations(bias, locs)\n            (1, 1)\n\n            >>> locs = [Location(wt=0, wd=500),\n            ...     Location(wt=1000,  wd=900),\n            ...     Location(wt=1200,  wd=900),\n            ...     Location(wt=-200,  wd=600),\n            ...     Location(wt=0,     wd=600),\n            ...     Location(wt=1000,  wd=600),\n            ...     Location(wt=1200,  wd=600),\n            ...     Location(wt=-200,  wd=300),\n            ...     Location(wt=0,     wd=300),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location wd:600, wt:0 >\n            >>> _testBiasFromLocations(bias, locs)\n            (5, 3)\n\n            >>> locs = [\n            ...     Location(wt=1,     sz=0),\n            ...     Location(wt=0,     sz=0),\n            ...     Location(wt=0.275, sz=0),\n            ...     Location(wt=0.275, sz=1),\n            ...     Location(wt=1,     sz=1),\n            ...     Location(wt=0.125, sz=0.4),\n            ...     Location(wt=1,     sz=0.4),\n            ...     Location(wt=0.6,   sz=0.4),\n            ...     Location(wt=0,     sz=0.4),\n            ...     Location(wt=0.275, sz=0.4),\n            ...     Location(wt=0,     sz=1),\n            ...     Location(wt=0.125, sz=1),\n            ...     Location(wt=0.6,   sz=0),\n            ...     Location(wt=0.125, sz=0),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location sz:0, wt:0 >\n            >>> _testBiasFromLocations(bias, locs)\n            (6, 7)\n\n            # Nothing lines up\n            >>> locs = [\n            ...     Location(pop=1),\n            ...     Location(snap=1),\n            ...     Location(crackle=1)]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location crackle:1 >\n            >>> _testBiasFromLocations(bias, locs)\n            (0, 2)\n\n            # ... why crackle? because it sorts first\n            >>> locs.sort()\n            >>> locs\n            [<Location crackle:1 >, <Location pop:1 >, <Location snap:1 >]\n\n            # Two things line up\n            >>> locs = [\n            ...     Location(pop=-1),\n            ...     Location(pop=1),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location pop:-1 >\n            >>> _testBiasFromLocations(bias, locs)\n            (1, 0)\n\n            # Two things line up\n            >>> locs = [\n            ...     Location(pop=-1, snap=-1),\n            ...     Location(pop=1, snap=0),\n            ...     Location(pop=1, snap=1),\n            ...     Location(pop=1, snap=1),\n            ...     ]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location pop:1, snap:1 >\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 1)\n\n            # Almost Nothing Lines Up 1\n            # An incomplete set of masters can \n            # create a situation in which there is nothing to interpolate.\n            # However, we still need to find a bias.\n            >>> locs = [\n            ...     Location(wt=1,     sz=0.4),\n            ...     Location(wt=0.275, sz=0.4),\n            ...     Location(wt=0,     sz=1),\n            ...     Location(wt=0.125, sz=0),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location sz:0.400, wt:0.275 >\n            >>> _testBiasFromLocations(bias, locs)\n            (1, 2)\n\n            # Almost Nothing Lines Up 2\n            >>> locs = [\n            ...     Location(wt=1,     sz=0.4),\n            ...     Location(wt=0.275, sz=0.4),\n            ...     Location(wt=0,     sz=1),\n            ...     Location(wt=0.6,   sz=1),\n            ...     Location(wt=0.125, sz=0),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location sz:0.400, wt:0.275 >\n            >>> _testBiasFromLocations(bias, locs)\n            (1, 3)\n\n            # A square on the origin\n            >>> locs = [\n            ...     Location(wt=0,     wd=0),\n            ...     Location(wt=1,     wd=0),\n            ...     Location(wt=0,     wd=1),\n            ...     Location(wt=1,     wd=1),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location wd:0, wt:0 >\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 1)\n\n            # A square, not on the origin\n            >>> locs = [\n            ...     Location(wt=100,     wd=100),\n            ...     Location(wt=200,     wd=100),\n            ...     Location(wt=100,     wd=200),\n            ...     Location(wt=200,     wd=200),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location wd:100, wt:100 >\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 1)\n\n            # A square, not on the origin\n            >>> locs = [\n            ...     Location(wt=200,     wd=100),\n            ...     Location(wt=100,     wd=200),\n            ...     Location(wt=200,     wd=200),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location wd:200, wt:200 >\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 0)\n\n            # Two axes, three masters\n            >>> locs = [\n            ...     Location(ct=0,       wd=0),\n            ...     Location(ct=0,       wd=1000),\n            ...     Location(ct=100,     wd=1000),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location ct:0, wd:1000 >\n\n            >>> _testBiasFromLocations(bias, locs)\n            (2, 0)\n\n            # Complex 4 D space\n            >>> locs = [\n            ...     Location(A=0,    H=0,    G=1000, W=0),\n            ...     Location(A=0,    H=0,    G=1000, W=700),\n            ...     Location(A=0,    H=0,    G=1000, W=1000),\n            ...     Location(A=0,    H=1000, G=0,    W=200),\n            ...     Location(A=0,    H=1000, G=0,    W=300),\n            ...     Location(A=0,    H=1000, G=0,    W=700),\n            ...     Location(A=0,    H=1000, G=0,    W=1000),\n            ...     Location(A=1000, H=0,    G=0,    W=0),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location A:0, G:0, H:1000, W:200 >\n\n            >>> locs = [\n            ...     Location(S=0,    U=0,      Wt=54,    Wd=385),\n            ...     Location(S=0,    U=268,    Wt=54,    Wd=1000),\n            ...     Location(S=8,    U=550,    Wt=851,   Wd=126),\n            ...     Location(S=8,    U=868,    Wt=1000,  Wd=1000),]\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location S:0, U:268, Wd:1000, Wt:54 >\n\n\n            # empty locs\n            >>> locs = []\n            >>> bias = biasFromLocations(locs)\n            >>> bias\n            <Location origin >\n        ' #NEWLINE# rel = [ ] #NEWLINE# for l in locs : #NEWLINE# #INDENT# rel . append ( ( l - bias ) . isOnAxis ( ) ) #NEWLINE# #UNINDENT# assert ( None in rel ) #NEWLINE# offAxis = rel . count ( False ) #NEWLINE# onAxis = ( ( len ( rel ) - offAxis ) - 1 ) #NEWLINE# return ( onAxis , offAxis )