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