-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeStyle][ruff] clean I001 ignore - Part 2 #60466
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
'StackTransform', | ||
'StickBreakingTransform', | ||
'TanhTransform', | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这会改 API 吧,为啥要这么改?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改前:
python
Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> dir(paddle.distribution)
['AbsTransform', 'AffineTransform', 'Bernoulli', 'Beta', 'Binomial', 'Categorical', 'Cauchy', 'ChainTransform', 'ContinuousBernoulli', 'Dirichlet', 'Distribution', 'ExpTransform', 'ExponentialFamily', 'Geometric', 'Gumbel', 'Independent', 'IndependentTransform', 'Laplace', 'LogNormal', 'Multinomial', 'MultivariateNormal', 'Normal', 'Poisson', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'TransformedDistribution', 'Uniform', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'bernoulli', 'beta', 'binomial', 'categorical', 'cauchy', 'constraint', 'continuous_bernoulli', 'dirichlet', 'distribution', 'exponential_family', 'geometric', 'gumbel', 'independent', 'kl', 'kl_divergence', 'laplace', 'lognormal', 'multinomial', 'multivariate_normal', 'normal', 'poisson', 'register_kl', 'transform', 'transformed_distribution', 'uniform', 'variable']
>>> len(dir(paddle.distribution))
69
>>> dir(paddle.distribution.transform)
['AbsTransform', 'AffineTransform', 'ChainTransform', 'ExpTransform', 'F', 'IndependentTransform', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'Type', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'constraint', 'distribution', 'enum', 'math', 'paddle', 'transformed_distribution', 'typing', 'variable']
>>> len(dir(paddle.distribution.transform))
32
>>>
修改后:
python
Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> dir(paddle.distribution)
['AbsTransform', 'AffineTransform', 'Bernoulli', 'Beta', 'Binomial', 'Categorical', 'Cauchy', 'ChainTransform', 'ContinuousBernoulli', 'Dirichlet', 'Distribution', 'ExpTransform', 'ExponentialFamily', 'Geometric', 'Gumbel', 'Independent', 'IndependentTransform', 'Laplace', 'LogNormal', 'Multinomial', 'MultivariateNormal', 'Normal', 'Poisson', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'TransformedDistribution', 'Uniform', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'bernoulli', 'beta', 'binomial', 'categorical', 'cauchy', 'constraint', 'continuous_bernoulli', 'dirichlet', 'distribution', 'exponential_family', 'geometric', 'gumbel', 'independent', 'kl', 'kl_divergence', 'laplace', 'lognormal', 'multinomial', 'multivariate_normal', 'normal', 'poisson', 'register_kl', 'transform', 'transformed_distribution', 'uniform', 'variable']
>>> len(dir(paddle.distribution))
69
>>> dir(paddle.distribution.transform)
['AbsTransform', 'AffineTransform', 'ChainTransform', 'ExpTransform', 'F', 'IndependentTransform', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'Type', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'constraint', 'distribution', 'enum', 'math', 'paddle', 'transformed_distribution', 'typing', 'variable']
>>> len(dir(paddle.distribution.transform))
31
>>>
在paddle.distribution.transform
下少了一个__all__
这个只有python/paddle/distribution/__init__.py
在使用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API 是看 __all__
不是看 dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
根据文档: Importing * From a Package, 移除会导致在from paddle.distribution.transform import *
时 Type
被导入,所以回滚了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这不是关键,关键是 Paddle 的 API 是看 __all__
的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paddle 的 API 似乎只看 __init__.py
下的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR types
Others
PR changes
Others
Description
相关链接: