# Path: openmodes/helpers.py
# class Identified(object):
#     """An object which can be uniquely identified by an id number. It is
#     assumed that any object which subclasses Identified is immutable, so that
#     its id can be used for caching complex results which depend on this object.
#     """
# 
#     def __init__(self):
#         self.id = uuid.uuid4()
# 
#     def __hash__(self):
#         return self.id.__hash__()
# 
#     def __eq__(self, other):
#         return hasattr(other, 'id') and (self.id == other.id)
# 
#     def __repr__(self):
#         "Represent the object by its id, in addition to its memory address"
#         return ("<%s at 0x%08x with id %s>" % (str(self.__class__)[8:-2],
#                                                id(self),
#                                                str(self.id)))
# 
# class PicklableRef(object):
#     """A weak reference which can be pickled. This is achieved by
#     creating a strong reference to the object at pickling time, then restoring
#     the weak reference when unpickling. Note that unless the object being
#     referenced is also pickled and referenced after unpickling, the weak
#     reference will be dead after unpickling.
#     """
# 
#     def __init__(self, obj, callback=None):
#         self.ref = weakref.ref(obj, callback)
# 
#     def __call__(self):
#         return self.ref()
# 
#     def __getstate__(self):
#         return {'ref': self.ref()}
# 
#     def __setstate__(self, state):
#         self.ref = weakref.ref(state['ref'])
# 
# Path: openmodes/material.py
# class IsotropicMaterial(Identified):
#     def __init__(self, name, epsilon_r, mu_r):
#     def eta(self, s):
#     def eta_r(self, s):
#     def n(self, s):


from openmodes.helpers import Identified, PicklableRef
from openmodes.material import PecMaterial
import numpy as np
import uuid
            if 'after' visited afterwards, otherwise not visited
        """
        if self in lowest:
            yield self
        else:
            if parent_order == 'before':
                yield self
            for part in self.children:
                for sub_part in part.iter_lowest(lowest, parent_order=parent_order):
                    yield sub_part
            if parent_order == 'after':
                yield self

    def __contains__(self, key):
        """Check if the given part is stored within this tree of parts"""
        return self == key or any(key in part for part in self.children)


class CompositePart(MultiPart):
    """A composite part containing sub-parts which can be treated as a
    whole. The sub-parts have this composite part as a parent.
    """
    def __init__(self, location=None):
        super(CompositePart, self).__init__(location)

    def add_part(self, part):
        "Add a part to this part, and become its parent part"
        if part.parent_ref is not None:
            raise ValueError("Part already has a different parent")
        self.children.append(part)

# Path: openmodes/helpers.py
# class Identified(object):
#     """An object which can be uniquely identified by an id number. It is
#     assumed that any object which subclasses Identified is immutable, so that
#     its id can be used for caching complex results which depend on this object.
#     """
# 
#     def __init__(self):
#         self.id = uuid.uuid4()
# 
#     def __hash__(self):
#         return self.id.__hash__()
# 
#     def __eq__(self, other):
#         return hasattr(other, 'id') and (self.id == other.id)
# 
#     def __repr__(self):
#         "Represent the object by its id, in addition to its memory address"
#         return ("<%s at 0x%08x with id %s>" % (str(self.__class__)[8:-2],
#                                                id(self),
#                                                str(self.id)))
# 
# class PicklableRef(object):
#     """A weak reference which can be pickled. This is achieved by
#     creating a strong reference to the object at pickling time, then restoring
#     the weak reference when unpickling. Note that unless the object being
#     referenced is also pickled and referenced after unpickling, the weak
#     reference will be dead after unpickling.
#     """
# 
#     def __init__(self, obj, callback=None):
#         self.ref = weakref.ref(obj, callback)
# 
#     def __call__(self):
#         return self.ref()
# 
#     def __getstate__(self):
#         return {'ref': self.ref()}
# 
#     def __setstate__(self, state):
#         self.ref = weakref.ref(state['ref'])
# 
# Path: openmodes/material.py
# class IsotropicMaterial(Identified):
#     def __init__(self, name, epsilon_r, mu_r):
#     def eta(self, s):
#     def eta_r(self, s):
#     def n(self, s):


# Path: openmodes/parts.py
from openmodes.helpers import Identified, PicklableRef
from openmodes.material import PecMaterial
import numpy as np
import uuid

            if 'after' visited afterwards, otherwise not visited
        """
        if self in lowest:
            yield self
        else:
            if parent_order == 'before':
                yield self
            for part in self.children:
                for sub_part in part.iter_lowest(lowest, parent_order=parent_order):
                    yield sub_part
            if parent_order == 'after':
                yield self

    def __contains__(self, key):
        """Check if the given part is stored within this tree of parts"""
        return self == key or any(key in part for part in self.children)


class CompositePart(MultiPart):
    """A composite part containing sub-parts which can be treated as a
    whole. The sub-parts have this composite part as a parent.
    """
    def __init__(self, location=None):
        super(CompositePart, self).__init__(location)

    def add_part(self, part):
        "Add a part to this part, and become its parent part"
        if part.parent_ref is not None:
            raise ValueError("Part already has a different parent")
        self.children.append(part)

        part.parent_ref = PicklableRef(self)