Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 _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, savepath: str, zip: bool = False, **kwargs):
"""
The NPYWriter creates a folder containing one subfolder for each stat.
Each subfolder contains a npy-file with the saturation value for each epoch.
This writer saves non-scalar values and can thus be used to save
the covariance-matrix.
:param savepath: The root folder to save the folder structure to
:param zip: Whether to zip the output folder after every invocation
"""
super(NPYWriter, self).__init__()
self.savepath = savepath
self.epoch_counter = {}
self.zip = zip