mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-14 06:22:38 +02:00
Changed refereences to iteritems() to items() for Py3 compat
This commit is contained in:
parent
46fc08a448
commit
82722305c3
3 changed files with 15 additions and 6 deletions
|
|
@ -342,7 +342,7 @@ class ParamConcatenation(object):
|
||||||
import operator
|
import operator
|
||||||
#py3 fix
|
#py3 fix
|
||||||
#self.parents = map(lambda x: x[0], sorted(parents.iteritems(), key=operator.itemgetter(1)))
|
#self.parents = map(lambda x: x[0], sorted(parents.iteritems(), key=operator.itemgetter(1)))
|
||||||
self.parents = map(lambda x: x[0], sorted(parents.tems(), key=operator.itemgetter(1)))
|
self.parents = map(lambda x: x[0], sorted(parents.items(), key=operator.itemgetter(1)))
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Get/set items, enable broadcasting
|
# Get/set items, enable broadcasting
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
|
||||||
|
|
@ -710,7 +710,7 @@ class OptimizationHandlable(Indexable):
|
||||||
self._highest_parent_.tie.collate_gradient()
|
self._highest_parent_.tie.collate_gradient()
|
||||||
#py3 fix
|
#py3 fix
|
||||||
#[np.put(g, i, c.gradfactor_non_natural(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__]
|
#[np.put(g, i, c.gradfactor_non_natural(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__]
|
||||||
[np.put(g, i, c.gradfactor_non_natural(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__]
|
[np.put(g, i, c.gradfactor_non_natural(self.param_array[i], g[i])) for c, i in self.constraints.items() if c != __fixed__]
|
||||||
if self._has_fixes(): return g[self._fixes_]
|
if self._has_fixes(): return g[self._fixes_]
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@ def toy_model():
|
||||||
|
|
||||||
class ListDictTestCase(unittest.TestCase):
|
class ListDictTestCase(unittest.TestCase):
|
||||||
def assertListDictEquals(self, d1, d2, msg=None):
|
def assertListDictEquals(self, d1, d2, msg=None):
|
||||||
for k,v in d1.iteritems():
|
#py3 fix
|
||||||
|
#for k,v in d1.iteritems():
|
||||||
|
for k,v in d1.items():
|
||||||
self.assertListEqual(list(v), list(d2[k]), msg)
|
self.assertListEqual(list(v), list(d2[k]), msg)
|
||||||
def assertArrayListEquals(self, l1, l2):
|
def assertArrayListEquals(self, l1, l2):
|
||||||
for a1, a2 in itertools.izip(l1,l2):
|
for a1, a2 in itertools.izip(l1,l2):
|
||||||
|
|
@ -39,8 +41,13 @@ class Test(ListDictTestCase):
|
||||||
def test_parameter_index_operations(self):
|
def test_parameter_index_operations(self):
|
||||||
pio = ParameterIndexOperations(dict(test1=np.array([4,3,1,6,4]), test2=np.r_[2:130]))
|
pio = ParameterIndexOperations(dict(test1=np.array([4,3,1,6,4]), test2=np.r_[2:130]))
|
||||||
piov = ParameterIndexOperationsView(pio, 20, 250)
|
piov = ParameterIndexOperationsView(pio, 20, 250)
|
||||||
self.assertListDictEquals(dict(piov.items()), dict(piov.copy().iteritems()))
|
#py3 fix
|
||||||
self.assertListDictEquals(dict(pio.iteritems()), dict(pio.copy().items()))
|
#self.assertListDictEquals(dict(piov.items()), dict(piov.copy().iteritems()))
|
||||||
|
self.assertListDictEquals(dict(piov.items()), dict(piov.copy().items()))
|
||||||
|
|
||||||
|
#py3 fix
|
||||||
|
#self.assertListDictEquals(dict(pio.iteritems()), dict(pio.copy().items()))
|
||||||
|
self.assertListDictEquals(dict(pio.items()), dict(pio.copy().items()))
|
||||||
|
|
||||||
self.assertArrayListEquals(pio.copy().indices(), pio.indices())
|
self.assertArrayListEquals(pio.copy().indices(), pio.indices())
|
||||||
self.assertArrayListEquals(piov.copy().indices(), piov.indices())
|
self.assertArrayListEquals(piov.copy().indices(), piov.indices())
|
||||||
|
|
@ -55,7 +62,9 @@ class Test(ListDictTestCase):
|
||||||
pickle.dump(piov, f)
|
pickle.dump(piov, f)
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
pio2 = pickle.load(f)
|
pio2 = pickle.load(f)
|
||||||
self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems()))
|
#py3 fix
|
||||||
|
#self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems()))
|
||||||
|
self.assertListDictEquals(dict(piov.items()), dict(pio2.items()))
|
||||||
|
|
||||||
def test_param(self):
|
def test_param(self):
|
||||||
param = Param('test', np.arange(4*2).reshape(4,2))
|
param = Param('test', np.arange(4*2).reshape(4,2))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue