Commit 7731d89d authored by Julien Chaumont's avatar Julien Chaumont Committed by Yuxin Wu

Fixed some deprecation warnings on python 3 (#1337)

parent bbf29a18
...@@ -5,7 +5,7 @@ from __future__ import division ...@@ -5,7 +5,7 @@ from __future__ import division
import itertools import itertools
import numpy as np import numpy as np
import pprint import pprint
from collections import defaultdict, deque, Mapping from collections import defaultdict, deque
from copy import copy from copy import copy
import six import six
import tqdm import tqdm
...@@ -17,6 +17,11 @@ from ..utils.utils import get_rng, get_tqdm, get_tqdm_kwargs ...@@ -17,6 +17,11 @@ from ..utils.utils import get_rng, get_tqdm, get_tqdm_kwargs
from ..utils.develop import log_deprecated from ..utils.develop import log_deprecated
from .base import DataFlow, DataFlowReentrantGuard, ProxyDataFlow, RNGDataFlow from .base import DataFlow, DataFlowReentrantGuard, ProxyDataFlow, RNGDataFlow
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
__all__ = ['TestDataSpeed', 'PrintData', 'BatchData', 'BatchDataByShape', 'FixedSizeData', 'MapData', __all__ = ['TestDataSpeed', 'PrintData', 'BatchData', 'BatchDataByShape', 'FixedSizeData', 'MapData',
'MapDataComponent', 'RepeatedData', 'RepeatedDataPoint', 'RandomChooseData', 'MapDataComponent', 'RepeatedData', 'RepeatedDataPoint', 'RandomChooseData',
'RandomMixData', 'JoinData', 'ConcatData', 'SelectComponent', 'RandomMixData', 'JoinData', 'ConcatData', 'SelectComponent',
......
...@@ -119,7 +119,10 @@ class MapGradient(GradientProcessor): ...@@ -119,7 +119,10 @@ class MapGradient(GradientProcessor):
If it return None, the gradient is discarded (hence no update to the variable will happen). If it return None, the gradient is discarded (hence no update to the variable will happen).
regex (str): used to match variables. Defaults to match all variables. regex (str): used to match variables. Defaults to match all variables.
""" """
if six.PY2:
args = inspect.getargspec(func).args args = inspect.getargspec(func).args
else:
args = inspect.getfullargspec(func).args
arg_num = len(args) - inspect.ismethod(func) arg_num = len(args) - inspect.ismethod(func)
assert arg_num in [1, 2], \ assert arg_num in [1, 2], \
"The function must take 1 or 2 arguments! ({})".format(args) "The function must take 1 or 2 arguments! ({})".format(args)
......
...@@ -122,9 +122,9 @@ def set_logger_dir(dirname, action=None): ...@@ -122,9 +122,9 @@ def set_logger_dir(dirname, action=None):
if dir_nonempty(dirname): if dir_nonempty(dirname):
if not action: if not action:
_logger.warn("""\ _logger.warning("""\
Log directory {} exists! Use 'd' to delete it. """.format(dirname)) Log directory {} exists! Use 'd' to delete it. """.format(dirname))
_logger.warn("""\ _logger.warning("""\
If you're resuming from a previous run, you can choose to keep it. If you're resuming from a previous run, you can choose to keep it.
Press any other key to exit. """) Press any other key to exit. """)
while not action: while not action:
......
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