Commit 8e5a46a4 authored by Yuxin Wu's avatar Yuxin Wu

don't throw when repr(imgaug) fails

parent 26d792d4
......@@ -9,6 +9,7 @@ import six
from six.moves import zip
from ...utils.utils import get_rng
from ...utils.argtools import log_once
from ..image import check_dtype
__all__ = ['Augmentor', 'ImageAugmentor', 'AugmentorList']
......@@ -81,6 +82,7 @@ class Augmentor(object):
Produce something like:
"imgaug.MyAugmentor(field1={self.field1}, field2={self.field2})"
"""
try:
argspec = inspect.getargspec(self.__init__)
assert argspec.varargs is None, "The default __repr__ doesn't work for vaargs!"
assert argspec.keywords is None, "The default __repr__ doesn't work for kwargs!"
......@@ -91,13 +93,16 @@ class Augmentor(object):
argstr = []
for idx, f in enumerate(fields):
assert hasattr(self, f), \
"Attribute {} not found! The default __repr__ only works if attributes match the constructor.".format(f)
"Attribute {} not found! Default __repr__ only works if attributes match the constructor.".format(f)
attr = getattr(self, f)
if idx >= index_field_has_default:
if attr is argspec.defaults[idx - index_field_has_default]:
continue
argstr.append("{}={}".format(f, pprint.pformat(attr)))
return "imgaug.{}({})".format(classname, ', '.join(argstr))
except AssertionError as e:
log_once(e.args[0], 'warn')
return super(Augmentor, self).__repr__()
__str__ = __repr__
......
......@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# File: parallel_map.py
import numpy as np
import time
import ctypes
import copy
import threading
......@@ -271,6 +272,7 @@ class MultiProcessMapDataZMQ(_ParallelMapData, _MultiProcessZMQDataFlow):
self._iter_worker = _repeat_iter(lambda: iter(self._proc_ids))
self._start_processes()
time.sleep(5) # TODO temporarily work around #673
self._fill_buffer() # pre-fill the bufer
def reset_state(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment