Skip to content
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][task 15] enable Ruff PLW3301 rule #57400

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

ooooo-create
Copy link
Contributor

@ooooo-create ooooo-create commented Sep 15, 2023

PR types

Others

PR changes

Others

Description

auto fix
@gouzil

@paddle-bot
Copy link

paddle-bot bot commented Sep 15, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@gouzil
Copy link
Member

gouzil commented Sep 16, 2023

这里需要讨论一下是否需要引入, 我觉得是可以引入的 @SigureMo

测试代码

import pytest, pytest_benchmark

op_idxs = [76,23,67,34,435,5,675,6435]
gpups_min_distributed_idx = 12
expected_result = 5


def test_1(benchmark):
	@benchmark
	def test_min():
		return min(*op_idxs, gpups_min_distributed_idx)

	res1 = test_min
	assert res1 == expected_result


def test_2(benchmark):
	@benchmark
	def test_min():
		return min(min(op_idxs),gpups_min_distributed_idx)

	res2 = test_min
	assert res2 == expected_result
==================================================================================================== test session starts =====================================================================================================
platform darwin -- Python 3.11.4, pytest-7.4.2, pluggy-1.3.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/gouzi/Downloads/paddle-test
plugins: anyio-3.7.1, benchmark-4.0.0
collected 2 items

demo.py ..                                                                                                                                                                                                             [100%]


--------------------------------------------------------------------------------------------- benchmark: 2 tests --------------------------------------------------------------------------------------------
Name (time in ns)          Min                       Max                  Mean                 StdDev              Median                 IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_1                373.7496 (1.0)      7,099,138.2499 (1.94)     1,024.1969 (1.0)      25,638.2390 (1.17)     645.5002 (1.0)      273.0003 (1.0)      264;3195      976.3748 (1.0)      188787           4
test_2                382.2856 (1.02)     3,656,401.2859 (1.0)      1,152.3761 (1.13)     21,821.5498 (1.0)      683.2857 (1.06)     314.5708 (1.15)     343;3133      867.7723 (0.89)     156789           7
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
===================================================================================================== 2 passed in 5.32s ======================================================================================================
==================================================================================================== test session starts =====================================================================================================
platform darwin -- Python 3.8.16, pytest-7.4.0, pluggy-1.2.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/gouzi/Downloads/paddle-test
plugins: xdoctest-1.1.1, xdist-3.3.1, benchmark-4.0.0, anyio-3.7.0
collected 2 items

demo.py ..                                                                                                                                                                                                             [100%]


--------------------------------------------------------------------------------------------- benchmark: 2 tests ---------------------------------------------------------------------------------------------
Name (time in ns)          Min                        Max                  Mean                 StdDev              Median                 IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_2                385.0000 (1.0)       9,192,435.8571 (1.0)      1,281.2945 (1.0)      36,979.7994 (1.0)      704.7143 (1.0)      322.7143 (1.0)      258;3661      780.4607 (1.0)      164366           7
test_1                444.0000 (1.15)     23,047,156.0000 (2.51)     1,690.1064 (1.32)     88,433.3687 (2.39)     891.0000 (1.26)     451.0000 (1.40)      67;2402      591.6787 (0.76)     160617           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
===================================================================================================== 2 passed in 6.85s ======================================================================================================

在新版本中应该是有对minmax做了优化

@SigureMo SigureMo changed the title [CodeStyle][task 15] enable Ruff PLW3301 rule in python/paddle/base [CodeStyle][task 15] enable Ruff PLW3301 rule Sep 16, 2023
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

pyproject.toml Show resolved Hide resolved
@SigureMo SigureMo merged commit 79eea6a into PaddlePaddle:develop Sep 18, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Sep 18, 2023
@ooooo-create ooooo-create deleted the ooooo/PLW3301 branch September 23, 2023 05:27
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants