-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[CodeStyle][ruff] fix E226
, NPY201
#60245
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
E226
, NPY201
, PLE0704
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.
self.assertEqual(out1, np.cast['int32'](self.rng1.random())) | ||
self.assertEqual( | ||
out1, np.asarray(self.rng1.random(), dtype=np.int32) | ||
) |
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.
2023-12-22 00:56:51 ======================================================================
2023-12-22 00:56:51 ERROR: test_static (test_seed_op.TestDropoutWithRandomSeedGenerator)
2023-12-22 00:56:51 ----------------------------------------------------------------------
2023-12-22 00:56:51 Traceback (most recent call last):
2023-12-22 00:56:51 File "/workspace/Paddle/build/test/legacy_test/test_seed_op.py", line 78, in test_static
2023-12-22 00:56:51 self.check_static_result(place=place)
2023-12-22 00:56:51 File "/workspace/Paddle/build/test/legacy_test/test_seed_op.py", line 73, in check_static_result
2023-12-22 00:56:51 out1, np.asarray(self.rng1.random(), dtype=np.int32)
2023-12-22 00:56:51 OverflowError: Python int too large to convert to C long
2023-12-22 00:56:51
2023-12-22 00:56:51 ----------------------------------------------------------------------
2023-12-22 00:56:51 Ran 3 tests in 0.056s
2023-12-22 00:56:51
2023-12-22 00:56:51 FAILED (errors=1)
看样子并不能对齐
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.
# Create dictionary of casting functions that wrap sequences
# indexed by type or type character
cast = _typedict()
for key in _concrete_types:
cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
cast 实现是这样的,直接 astype 可以么?
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.
cast 实现是这样的,直接 astype 可以么?
可以
E226
, NPY201
, PLE0704
E226
, NPY201
链接的话,astral-sh/ruff#7702 里的三个链接就很好了,都是非常有用的参考链接 |
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.
* fix ruff preview * fix cast
PR types
Others
PR changes
Others
Description
修复
E226
,NPY201
存量,注意这些为 preview 功能Numpy 2.0 适配情况:
np.cast
->np. asarray
np.trapz
->scipy.interpolate.trapezoid
np.in1d
->np.isin
np.row_stack
->np.vstack
np.cross
-> ❓numpy.testing.assert_array_equal
参数位置改变 (但是我看好像只是换了个名字 1.26、dev)numpy.testing.assert_array_almost_equal
参数位置改变 (同上 1.26、dev)相关链接: