Commit ad0cc7b5 authored by Martin Reinecke's avatar Martin Reinecke

fix metaclasses

parent d2675589
......@@ -16,10 +16,10 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from functools import reduce
from ..utilities import NiftyMetaBase
from ..utilities import NiftyMeta
class Domain(NiftyMetaBase()):
class Domain(metaclass=NiftyMeta):
"""The abstract class repesenting a (structured or unstructured) domain.
"""
def __repr__(self):
......
......@@ -15,10 +15,10 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..utilities import NiftyMetaBase
from ..utilities import NiftyMeta
class Energy(NiftyMetaBase()):
class Energy(metaclass=NiftyMeta):
"""Provides the functional used by minimization schemes.
The Energy object is an implementation of a scalar function including its
......
......@@ -16,11 +16,11 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..logger import logger
from ..utilities import NiftyMetaBase
from ..utilities import NiftyMeta
import numpy as np
class IterationController(NiftyMetaBase()):
class IterationController(metaclass=NiftyMeta):
"""The abstract base class for all iteration controllers.
An iteration controller is an object that monitors the progress of a
minimization iteration. At the begin of the minimization, its start()
......
......@@ -15,7 +15,7 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..utilities import NiftyMetaBase
from ..utilities import NiftyMeta
from ..logger import logger
import numpy as np
......@@ -103,7 +103,7 @@ class LineEnergy(object):
return res.real
class LineSearch(NiftyMetaBase()):
class LineSearch(metaclass=NiftyMeta):
"""Class for finding a step size that satisfies the strong Wolfe
conditions.
......
......@@ -15,10 +15,10 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from ..utilities import NiftyMetaBase
from ..utilities import NiftyMeta
class Minimizer(NiftyMetaBase()):
class Minimizer(metaclass=NiftyMeta):
"""A base class used by all minimizers."""
# MR FIXME: the docstring is partially ignored by Sphinx. Why?
......
......@@ -16,10 +16,10 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
from ..utilities import NiftyMetaBase, indent
from ..utilities import NiftyMeta, indent
class Operator(NiftyMetaBase()):
class Operator(metaclass=NiftyMeta):
"""Transforms values defined on one domain into values defined on another
domain, and can also provide the Jacobian.
"""
......
......@@ -20,10 +20,9 @@ from itertools import product
from functools import reduce
import numpy as np
from future.utils import with_metaclass
__all__ = ["get_slice_list", "safe_cast", "parse_spaces", "infer_space",
"memo", "NiftyMetaBase", "my_sum", "my_lincomb_simple",
"memo", "NiftyMeta", "my_sum", "my_lincomb_simple",
"my_lincomb", "indent",
"my_product", "frozendict", "special_add_at", "iscomplextype"]
......@@ -178,10 +177,6 @@ class NiftyMeta(_DocStringInheritor):
pass
def NiftyMetaBase():
return with_metaclass(NiftyMeta, type('NewBase', (object,), {}))
class frozendict(collections.abc.Mapping):
"""
An immutable wrapper around dictionaries that implements the complete
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment