mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-08 19:42:39 +02:00
Used 'six' to support Py3 and Py2 simultaneously
This commit is contained in:
parent
7930eb646f
commit
e5587cf234
2 changed files with 12 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2014, Max Zwiessele, James Hensman
|
||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||
|
||||
|
||||
import six # For metaclass support in Python 2 and 3 simultaneously
|
||||
import numpy; np = numpy
|
||||
import itertools
|
||||
from re import compile, _pattern_type
|
||||
|
|
@ -27,7 +27,8 @@ class ParametersChangedMeta(type):
|
|||
self.parameters_changed()
|
||||
return self
|
||||
|
||||
class Parameterized(Parameterizable,metaclass=ParametersChangedMeta):
|
||||
@six.add_metaclass(ParametersChangedMeta)
|
||||
class Parameterized(Parameterizable):
|
||||
"""
|
||||
Parameterized class
|
||||
|
||||
|
|
@ -73,8 +74,9 @@ class Parameterized(Parameterizable,metaclass=ParametersChangedMeta):
|
|||
# Metaclass for parameters changed after init.
|
||||
# This makes sure, that parameters changed will always be called after __init__
|
||||
# **Never** call parameters_changed() yourself
|
||||
#This is ignored in Python 3 -- you need to put the meta class in the
|
||||
__metaclass__ = ParametersChangedMeta
|
||||
#This is ignored in Python 3 -- you need to put the meta class in the function definition.
|
||||
#__metaclass__ = ParametersChangedMeta
|
||||
#The six module is used to support both Python 2 and 3 simultaneously
|
||||
#===========================================================================
|
||||
def __init__(self, name=None, parameters=[], *a, **kw):
|
||||
super(Parameterized, self).__init__(name=name, *a, **kw)
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@ from .kernel_slice_operations import KernCallsViaSlicerMeta
|
|||
from ...util.caching import Cache_this
|
||||
from GPy.core.parameterization.observable_array import ObsAr
|
||||
from functools import reduce
|
||||
import six
|
||||
|
||||
|
||||
|
||||
class Kern(Parameterized,metaclass=KernCallsViaSlicerMeta):
|
||||
@six.add_metaclass(KernCallsViaSlicerMeta)
|
||||
class Kern(Parameterized):
|
||||
#===========================================================================
|
||||
# This adds input slice support. The rather ugly code for slicing can be
|
||||
# found in kernel_slice_operations
|
||||
# __mataclass__ is ignored in Python 3 - needs to be put in the function definiton
|
||||
__metaclass__ = KernCallsViaSlicerMeta
|
||||
# __meataclass__ is ignored in Python 3 - needs to be put in the function definiton
|
||||
#__metaclass__ = KernCallsViaSlicerMeta
|
||||
#Here, we use the Python module six to support Py3 and Py2 simultaneously
|
||||
#===========================================================================
|
||||
_support_GPU=False
|
||||
def __init__(self, input_dim, active_dims, name, useGPU=False, *a, **kw):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue