# Path: pypet/pypetlogging.py
# class HasLogger(HasSlots):
#     """Abstract super class that automatically adds a logger to a class.
# 
#     To add a logger to a sub-class of yours simply call ``myobj._set_logger(name)``.
#     If ``name=None`` the logger is chosen as follows:
# 
#         ``self._logger = logging.getLogger(self.__class.__.__module__ + '.' + self.__class__.__name__)``
# 
#     The logger can be accessed via ``myobj._logger``.
# 
#     """
# 
#     __slots__ = ('_logger',)
# 
#     def __getstate__(self):
#         """Called for pickling.
# 
#         Removes the logger to allow pickling and returns a copy of `__dict__`.
# 
#         """
#         state_dict = super(HasLogger, self).__getstate__()
#         if '_logger' in state_dict:
#             # Pickling does not work with loggers objects,
#             # so we just keep the logger's name:
#             state_dict['_logger'] = self._logger.name
#         return state_dict
# 
#     def __setstate__(self, statedict):
#         """Called after loading a pickle dump.
# 
#         Restores `__dict__` from `statedict` and adds a new logger.
# 
#         """
#         super(HasLogger, self).__setstate__(statedict)
#         if '_logger' in statedict:
#             # If we re-instantiate the component the
#             # logger attribute only contains a name,
#             # so we also need to re-create the logger:
#             self._set_logger(statedict['_logger'])
# 
#     def _set_logger(self, name=None):
#         """Adds a logger with a given `name`.
# 
#         If no name is given, name is constructed as
#         `type(self).__name__`.
# 
#         """
#         if name is None:
#             cls = self.__class__
#             name = '%s.%s' % (cls.__module__, cls.__name__)
#         self._logger = logging.getLogger(name)


from brian2 import Network, second
from pypet.pypetlogging import HasLogger
"""Module for easy compartmental implementation of a BRIAN2 network.

Build parts of a network via subclassing :class:`~pypet.brian2.network.NetworkComponent` and
:class:`~pypet.brian2.network.NetworkAnalyser` for recording and statistical analysis.

Specify a :class:`~pypet.brian2.network.NetworkRunner` (subclassing optionally) that handles
the execution of your experiment in different subruns. Subruns can be defined
as :class:`~pypet.brian2.parameter.Brian2Parameter` instances in a particular
trajectory group. You must add to every parameter's :class:`~pypet.annotations.Annotations` the
attribute `order`. This order must be an integer specifying the index or order
the subrun should about to be executed in.

The creation and management of a BRIAN2 network is handled by the
:class:`~pypet.brian2.network.NetworkManager` (no need for subclassing). Pass your
components, analyser and your runner to the manager.

Pass the :func:`~pypet.brian2.network.run_network` function together with a
:class:`~pypet.brian2.network.NetworkManager` to your main environment function
:func:`~pypet.environment.Environment.run` to start a simulation and parallel
parameter exploration. Be aware that in case of a *pre-built* network,
successful parameter exploration
requires parallel processing (see :class:`~pypet.brian2.network.NetworkManager`).

"""

__author__ = 'Robert Meyer'





# Path: pypet/pypetlogging.py
# class HasLogger(HasSlots):
#     """Abstract super class that automatically adds a logger to a class.
# 
#     To add a logger to a sub-class of yours simply call ``myobj._set_logger(name)``.
#     If ``name=None`` the logger is chosen as follows:
# 
#         ``self._logger = logging.getLogger(self.__class.__.__module__ + '.' + self.__class__.__name__)``
# 
#     The logger can be accessed via ``myobj._logger``.
# 
#     """
# 
#     __slots__ = ('_logger',)
# 
#     def __getstate__(self):
#         """Called for pickling.
# 
#         Removes the logger to allow pickling and returns a copy of `__dict__`.
# 
#         """
#         state_dict = super(HasLogger, self).__getstate__()
#         if '_logger' in state_dict:
#             # Pickling does not work with loggers objects,
#             # so we just keep the logger's name:
#             state_dict['_logger'] = self._logger.name
#         return state_dict
# 
#     def __setstate__(self, statedict):
#         """Called after loading a pickle dump.
# 
#         Restores `__dict__` from `statedict` and adds a new logger.
# 
#         """
#         super(HasLogger, self).__setstate__(statedict)
#         if '_logger' in statedict:
#             # If we re-instantiate the component the
#             # logger attribute only contains a name,
#             # so we also need to re-create the logger:
#             self._set_logger(statedict['_logger'])
# 
#     def _set_logger(self, name=None):
#         """Adds a logger with a given `name`.
# 
#         If no name is given, name is constructed as
#         `type(self).__name__`.
# 
#         """
#         if name is None:
#             cls = self.__class__
#             name = '%s.%s' % (cls.__module__, cls.__name__)
#         self._logger = logging.getLogger(name)


# Path: pypet/brian2/network.py
from brian2 import Network, second
from pypet.pypetlogging import HasLogger

"""Module for easy compartmental implementation of a BRIAN2 network.

Build parts of a network via subclassing :class:`~pypet.brian2.network.NetworkComponent` and
:class:`~pypet.brian2.network.NetworkAnalyser` for recording and statistical analysis.

Specify a :class:`~pypet.brian2.network.NetworkRunner` (subclassing optionally) that handles
the execution of your experiment in different subruns. Subruns can be defined
as :class:`~pypet.brian2.parameter.Brian2Parameter` instances in a particular
trajectory group. You must add to every parameter's :class:`~pypet.annotations.Annotations` the
attribute `order`. This order must be an integer specifying the index or order
the subrun should about to be executed in.

The creation and management of a BRIAN2 network is handled by the
:class:`~pypet.brian2.network.NetworkManager` (no need for subclassing). Pass your
components, analyser and your runner to the manager.

Pass the :func:`~pypet.brian2.network.run_network` function together with a
:class:`~pypet.brian2.network.NetworkManager` to your main environment function
:func:`~pypet.environment.Environment.run` to start a simulation and parallel
parameter exploration. Be aware that in case of a *pre-built* network,
successful parameter exploration
requires parallel processing (see :class:`~pypet.brian2.network.NetworkManager`).

"""

__author__ = 'Robert Meyer'





class NetworkComponent(HasLogger):