Skip to content

Commit

Permalink
add optional custom logger to Berny()
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrmnn committed Feb 20, 2020
1 parent 2933d32 commit 7e15ce8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "pyberny"
version = "0.6.1"
version = "0.6.2"
description = "Molecular/crystal structure optimizer"
readme = "README.md"
authors = ["Jan Hermann <[email protected]>"]
Expand Down
9 changes: 6 additions & 3 deletions src/berny/berny.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from . import Math
from .coords import InternalCoords

__version__ = '0.3.1'
__version__ = '0.3.2'
__all__ = ['Berny']

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -59,6 +59,7 @@ class Berny(Generator):
restart (dict): start from a state saved from previous run
using ``debug=True``
maxsteps (int): abort after maximum number of steps
logger (:class:`logging.Logger`): alternative logger to use
params: parameters that override the :data:`~berny.berny.defaults`
The Berny object is to be used as follows::
Expand All @@ -74,13 +75,15 @@ class State(object):

Point = namedtuple('Point', 'q E g')

def __init__(self, geom, debug=False, restart=None, maxsteps=100, **params):
def __init__(
self, geom, debug=False, restart=None, maxsteps=100, logger=None, **params
):
self._debug = debug
self._maxsteps = maxsteps
self._converged = False
self._n = 0
self._log_extra = {'step': self._n}
self._log = BernyAdapter(log, self._log_extra)
self._log = BernyAdapter(logger or log, self._log_extra)
s = self._state = Berny.State()
if restart:
vars(s).update(restart)
Expand Down

0 comments on commit 7e15ce8

Please sign in to comment.