Skip to content

Commit

Permalink
add __all__=[] to python files not in API public list; import * only …
Browse files Browse the repository at this point in the history
…support in API public list files
  • Loading branch information
zhiboniu committed Apr 29, 2021
1 parent 75282e7 commit 11b29d1
Show file tree
Hide file tree
Showing 105 changed files with 201 additions and 15 deletions.
2 changes: 2 additions & 0 deletions python/paddle/dataset/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import six
from six.moves import cPickle as pickle

__all__ = []

URL_PREFIX = 'https://dataset.bj.bcebos.com/cifar/'
CIFAR10_URL = URL_PREFIX + 'cifar-10-python.tar.gz'
CIFAR10_MD5 = 'c58f30108f718f92721af3b95e74349a'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import six.moves.cPickle as pickle
import glob

__all__ = []

HOME = os.path.expanduser('~')
DATA_HOME = os.path.join(HOME, '.cache', 'paddle', 'dataset')

Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/conll05.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import paddle.utils.deprecated as deprecated
from six.moves import zip, range

__all__ = []

DATA_URL = 'http://paddlemodels.bj.bcebos.com/conll05st/conll05st-tests.tar.gz'
DATA_MD5 = '387719152ae52d60422c016e92a742fc'
WORDDICT_URL = 'http://paddlemodels.bj.bcebos.com/conll05st%2FwordDict.txt'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/flowers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from six.moves import cPickle as pickle
from paddle.utils import try_import

__all__ = []

DATA_URL = 'http://paddlemodels.bj.bcebos.com/flowers/102flowers.tgz'
LABEL_URL = 'http://paddlemodels.bj.bcebos.com/flowers/imagelabels.mat'
SETID_URL = 'http://paddlemodels.bj.bcebos.com/flowers/setid.mat'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import tarfile
import six.moves.cPickle as pickle

__all__ = []


def _check_cv2():
if cv2 is None:
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import string
import six

__all__ = []

#URL = 'http://ai.stanford.edu/%7Eamaas/data/sentiment/aclImdb_v1.tar.gz'
URL = 'https://dataset.bj.bcebos.com/imdb%2FaclImdb_v1.tar.gz'
MD5 = '7c2ac02c03563afcf9b574c7e56c153a'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/imikolov.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import tarfile
import six

__all__ = []

#URL = 'http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz'
URL = 'https://dataset.bj.bcebos.com/imikolov%2Fsimple-examples.tgz'
MD5 = '30177ea32e27c525793142b6bf2c8e2d'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import struct
from six.moves import range

__all__ = []

URL_PREFIX = 'https://dataset.bj.bcebos.com/mnist/'
TEST_IMAGE_URL = URL_PREFIX + 't10k-images-idx3-ubyte.gz'
TEST_IMAGE_MD5 = '9fb629c4189551a2d022fa330f9573f3'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/movielens.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import six
import paddle.compat as cpt

__all__ = []

age_table = [1, 18, 25, 35, 45, 50, 56]

#URL = 'http://files.grouplens.org/datasets/movielens/ml-1m.zip'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/cifar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import paddle.dataset.cifar
import unittest

__all__ = []


class TestCIFAR(unittest.TestCase):
def check_reader(self, reader):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/flowers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import paddle.dataset.flowers
import unittest

__all__ = []


class TestFlowers(unittest.TestCase):
def check_reader(self, reader):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/imdb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import unittest
import re

__all__ = []

TRAIN_POS_PATTERN = re.compile(r"aclImdb/train/pos/.*\.txt$")
TRAIN_NEG_PATTERN = re.compile(r"aclImdb/train/neg/.*\.txt$")
TRAIN_PATTERN = re.compile(r"aclImdb/train/.*\.txt$")
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/imikolov_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

WORD_DICT = paddle.dataset.imikolov.build_dict()

__all__ = []


class TestMikolov(unittest.TestCase):
def check_reader(self, reader, n):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/mnist_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import paddle.dataset.mnist
import unittest

__all__ = []


class TestMNIST(unittest.TestCase):
def check_reader(self, reader):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import paddle.dataset.image as image

__all__ = []


class Image(unittest.TestCase):
def test_resize_flip_chw(self):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/voc2012_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import paddle.dataset.voc2012
import unittest

__all__ = []


class TestVOC(unittest.TestCase):
def check_reader(self, reader):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/tests/wmt16_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import paddle.dataset.wmt16
import unittest

__all__ = []


class TestWMT16(unittest.TestCase):
def checkout_one_sample(self, sample):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/uci_housing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import paddle.dataset.common
import paddle.utils.deprecated as deprecated

__all__ = []

URL = 'http://paddlemodels.bj.bcebos.com/uci_housing/housing.data'
MD5 = 'd4accdce7a25600298819f8e28e8d593'
feature_names = [
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/dataset/voc2012.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
import io
import numpy as np
from paddle.dataset.common import download
from paddle.dataset.image import *
import paddle.utils.deprecated as deprecated
from PIL import Image

__all__ = []

VOC_URL = 'http://host.robots.ox.ac.uk/pascal/VOC/voc2012/\
VOCtrainval_11-May-2012.tar'

Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/wmt14.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import paddle.compat as cpt
import paddle.utils.deprecated as deprecated

__all__ = []

URL_DEV_TEST = ('http://www-lium.univ-lemans.fr/~schwenk/'
'cslm_joint_paper/data/dev+test.tgz')
MD5_DEV_TEST = '7d7897317ddd8ba0ae5c5fa7248d3ff5'
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/dataset/wmt16.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import paddle.compat as cpt
import paddle.utils.deprecated as deprecated

__all__ = []

DATA_URL = ("http://paddlemodels.bj.bcebos.com/wmt/wmt16.tar.gz")
DATA_MD5 = "0c38be43600334966403524a40dcd81e"

Expand Down
2 changes: 2 additions & 0 deletions python/paddle/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
from .io import save # noqa: F401
from .io import load # noqa: F401
from ..fluid.dygraph.parallel import DataParallel # noqa: F401

__all__ = []
7 changes: 2 additions & 5 deletions python/paddle/framework/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = [
"dtype", "uint8", "int8", "int16", "int32", "int64", "bfloat16", "float16",
"float32", "float64", "complex64", "complex128", "bool"
]

from ..fluid.core import VarDesc

dtype = VarDesc.VarType
Expand All @@ -38,3 +33,5 @@
complex128 = VarDesc.VarType.COMPLEX128

bool = VarDesc.VarType.BOOL

__all__ = []
2 changes: 2 additions & 0 deletions python/paddle/framework/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import numpy as np
from contextlib import contextmanager

__all__ = []


def set_default_dtype(d):
"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/framework/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from paddle.fluid.dygraph.io import _construct_program_holders, _construct_params_and_buffers
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX, INFER_PARAMS_INFO_SUFFIX

__all__ = []


def _build_saved_state_dict(state_dict):
save_dict = {}
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/framework/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import paddle.fluid as fluid
from paddle.fluid import core

__all__ = []


def seed(seed):
"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
from ..fluid.clip import ClipGradByGlobalNorm # noqa: F401
from ..fluid.clip import ClipGradByNorm # noqa: F401
from ..fluid.clip import ClipGradByValue # noqa: F401

__all__ = []
2 changes: 2 additions & 0 deletions python/paddle/nn/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@

from ..fluid.layers import BeamSearchDecoder # noqa: F401
from ..fluid.layers import dynamic_decode # noqa: F401

__all__ = []
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from ...fluid.data_feeder import check_variable_and_dtype, check_dtype
import paddle

__all__ = []


def elu(x, alpha=1.0, name=None):
r"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from ...fluid import core, layers
from ...fluid.data_feeder import check_variable_and_dtype

__all__ = []


def interpolate(x,
size=None,
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from ...fluid.param_attr import ParamAttr
from ...fluid.layer_helper import LayerHelper

__all__ = []


def _is_list_or_tuple(input):
return isinstance(input, (list, tuple))
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from ...fluid.layers.layer_function_generator import templatedoc
from ...fluid.layers.sequence_lod import sequence_mask

__all__ = []


def diag_embed(input, offset=0, dim1=-2, dim2=-1):
"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from ...fluid.layers import core
from ...fluid.data_feeder import check_variable_and_dtype, check_dtype

__all__ = []


def one_hot(x, num_classes, name=None):
"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from ...fluid.framework import Variable
from paddle.utils import deprecated

__all__ = []


def binary_cross_entropy(input, label, weight=None, reduction='mean',
name=None):
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from ...fluid import core, dygraph_utils
import numbers

__all__ = []


def normalize(x, p=2, axis=1, epsilon=1e-12, name=None):
r"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from ...fluid.layers import utils, LayerHelper, unsqueeze, squeeze
from ...fluid.data_feeder import check_type, check_variable_and_dtype

__all__ = []


def _is_list_or_tuple(input):
return isinstance(input, (list, tuple))
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/functional/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from ...fluid import dygraph_utils
import numpy as np

__all__ = []


def affine_grid(theta, out_shape, align_corners=True, name=None):
"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from ...fluid.data_feeder import check_type
from ...fluid.initializer import NumpyArrayInitializer

__all__ = []


class Assign(NumpyArrayInitializer):
"""Init an parameter with a numpy array, list, or tensor.
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# TODO: define the initializers of Constant in neural network
from ...fluid.initializer import ConstantInitializer

__all__ = []


class Constant(ConstantInitializer):
"""Implement the constant initializer.
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/kaiming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# TODO: define the initializers of Kaiming functions in neural network
from ...fluid.initializer import MSRAInitializer

__all__ = []


class KaimingNormal(MSRAInitializer):
r"""Implements the Kaiming Normal initializer
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from ...fluid.initializer import NormalInitializer
from ...fluid.initializer import TruncatedNormalInitializer

__all__ = []


class Normal(NormalInitializer):
"""The Random Normal (Gaussian) distribution initializer.
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from ...fluid.initializer import UniformInitializer

__all__ = []


class Uniform(UniformInitializer):
"""The random uniform distribution initializer.
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/initializer/xavier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from ...fluid.initializer import XavierInitializer

__all__ = []


class XavierNormal(XavierInitializer):
r"""
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/nn/layer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@
from .vision import PixelShuffle # noqa: F401
from .distance import PairwiseDistance # noqa: F401
from .container import LayerDict # noqa: F401

__all__ = []
Loading

1 comment on commit 11b29d1

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.