Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_writer(self, save_to, writers_args) -> \
delve.writers.AbstractWriter:
"""Create a writer to log history to `writer_dir`."""
if issubclass(type(save_to), delve.writers.AbstractWriter):
return save_to
if isinstance(save_to, list):
all_writers = []
for saver in save_to:
all_writers.append(self._get_writer(save_to=saver,
writers_args=writers_args))
return CompositWriter(all_writers)
if hasattr(delve, save_to):
writer = getattr(delve, save_to)(**writers_args)
else:
raise ValueError('Illegal argument for save_to "{}"'.
format(save_to))
return writer
def _warn_if_covariance_not_saveable(self, stats: List[str]):
warn = False
if 'cov' in stats:
if isinstance(self.writer, CompositWriter):
for writer in self.writer.writers:
if isinstance(writer, NPYWriter):
return
warn = True
elif not isinstance(self.writer, NPYWriter):
warn = True
if warn:
warnings.warn("'cov' was selected as stat, but 'npy' (NPYWriter)"
"is not used as a save strategy, which is the only"
def __init__(self, writers: List[AbstractWriter]):
"""
This writer combines multiple writers.
:param writers: List of writers. Each writer is called when the CompositeWriter is invoked.
"""
super(CompositWriter, self).__init__()
self.writers = writers