Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide user option to override default logging #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions zeus/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,25 @@ def __init__(self,
check_walkers=True,
shuffle_ensemble=True,
light_mode=False,
logger=None,
):

# Set up logger
self.logger = logging.getLogger()
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
handler = logging.StreamHandler()
self.logger.addHandler(handler)
if verbose:
self.logger.setLevel(logging.INFO)
if logger is None:
self.logger = logging.getLogger()
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
handler = logging.StreamHandler()
self.logger.addHandler(handler)
if verbose:
self.logger.setLevel(logging.INFO)
else:
self.logger.setLevel(logging.WARNING)
elif isinstance(logger, logging.Logger):
self.logger = logger
else:
self.logger.setLevel(logging.WARNING)

raise ValueError("logger should be an instance of logging.Logger or None")
# Parse the move schedule
if moves is None:
self._moves = [DifferentialMove()]
Expand Down Expand Up @@ -724,4 +730,4 @@ def sample(self,
class sampler(EnsembleSampler):
def __init__(self, *args, **kwargs):
logging.warning('The sampler class has been deprecated. Please use the new EnsembleSampler class.')
super().__init__(*args, **kwargs)
super().__init__(*args, **kwargs)