schrodinger.infra.mmerr module¶
Utility functions for the mmerr library.
Copyright Schrodinger, LLC. All rights reserved.
-
schrodinger.infra.mmerr.
push_level
(mmerr_level, mmerr_handle=None)¶ Set the specified mmerr level and push the previous level onto a stack.
Parameters: - mmerr_level (int) – The logging level to use.
- mmerr_handle (int) – The mmerr handle to use. Defaults to mm.error_handler.
-
schrodinger.infra.mmerr.
pop_level
(mmerr_handle=None)¶ Pop the mmerr level stack and set logging level to the previous value.
Return the mmerr level that has been set (i.e. the current logging level in use after the function returns).
Parameters: mmerr_handle (int) – The mmerr handle to use. Defaults to mm.error_handler.
-
class
schrodinger.infra.mmerr.
ErrorHandler
(queued=False, silent=False, level=None)¶ Bases:
object
A class for managing mmerr handlers.
-
__init__
(queued=False, silent=False, level=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
pop_errors
()¶ Return any queued errors and clear the queue.
-
__del__
()¶
-
push_level
(level)¶
-
pop_level
()¶
-
level
(level)¶ Enter a context in which the mmerr level is set to
level
. Public interface to context manager functionality.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.infra.mmerr', '__doc__': '\n A class for managing mmerr handlers.\n\n ', '__init__': <function ErrorHandler.__init__>, 'pop_errors': <function ErrorHandler.pop_errors>, '__del__': <function ErrorHandler.__del__>, 'push_level': <function ErrorHandler.push_level>, 'pop_level': <function ErrorHandler.pop_level>, 'level': <function ErrorHandler.level>, '__dict__': <attribute '__dict__' of 'ErrorHandler' objects>, '__weakref__': <attribute '__weakref__' of 'ErrorHandler' objects>})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.infra.mmerr'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
schrodinger.infra.mmerr.
Level
(level=4, handle=None)¶ Bases:
contextlib.ContextDecorator
Change mmerr level within a context or while a function is being run. Uses the default mm.error_handler level (MMERR_WARNING) if none is provided. Uses the default mm.error_handle if none is provided.
-
__init__
(level=4, handle=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
__enter__
()¶ Enter the context manager: changes error level for the specified error handler.
-
__exit__
(exc_type, exc_value, traceback)¶ Exit context manager: return mmerr reporting to its previous level.
Exception arguments are unused, but required by context manager signature.
-
__call__
(func)¶ Call self as a function.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.infra.mmerr', '__doc__': '\n Change mmerr level within a context or while a function is being run.\n Uses the default mm.error_handler level (MMERR_WARNING) if none is provided.\n Uses the default mm.error_handle if none is provided.\n ', '__init__': <function Level.__init__>, '__enter__': <function Level.__enter__>, '__exit__': <function Level.__exit__>})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.infra.mmerr'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
schrodinger.infra.mmerr.
disable_mmerr
(handle=None)¶ Bases:
schrodinger.infra.mmerr.Level
Turn off mmerr reporting within a context or while a function is being run. Uses the default mm.error_handle if none is provided
-
__init__
(handle=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
__call__
(func)¶ Call self as a function.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.infra.mmerr', '__doc__': '\n Turn off mmerr reporting within a context or while a function is being run.\n Uses the default mm.error_handle if none is provided\n ', '__init__': <function disable_mmerr.__init__>})¶
-
__dir__
() → list¶ default dir() implementation
-
__enter__
()¶ Enter the context manager: changes error level for the specified error handler.
-
__eq__
¶ Return self==value.
-
__exit__
(exc_type, exc_value, traceback)¶ Exit context manager: return mmerr reporting to its previous level.
Exception arguments are unused, but required by context manager signature.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.infra.mmerr'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
schrodinger.infra.mmerr.
Capture
(handle=-1)¶ Bases:
object
Capture all mmerr in a context. At the end of the context, messages will be available in the messages attribute. Messages are not printed.
usage:
with Capture() as captured: # make some mm calls print captured.messages
-
__init__
(handle=-1)¶ Initialize self. See help(type(self)) for accurate signature.
-
__enter__
()¶
-
__exit__
(*exc_args)¶
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.infra.mmerr', '__doc__': '\n Capture all mmerr in a context. At the end of the context, messages will\n be available in the messages attribute. Messages are not printed.\n\n usage::\n\n with Capture() as captured:\n # make some mm calls\n print captured.messages\n\n ', '__init__': <function Capture.__init__>, '__enter__': <function Capture.__enter__>, '__exit__': <function Capture.__exit__>, '__dict__': <attribute '__dict__' of 'Capture' objects>, '__weakref__': <attribute '__weakref__' of 'Capture' objects>})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.infra.mmerr'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-