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][PLR0911] too-many-return-statements #52153

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions python/paddle/fluid/tests/unittests/test_cast_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,21 @@


def convert_to_dtype_(dtype):
if dtype == 5:
return core.VarDesc.VarType.FP32
elif dtype == 6:
return core.VarDesc.VarType.FP64
elif dtype == 4:
return core.VarDesc.VarType.FP16
elif dtype == 2:
return core.VarDesc.VarType.INT32
elif dtype == 1:
return core.VarDesc.VarType.INT16
elif dtype == 3:
return core.VarDesc.VarType.INT64
elif dtype == 0:
return core.VarDesc.VarType.BOOL
elif dtype == 22:
return core.VarDesc.VarType.BF16
elif dtype == 20:
return core.VarDesc.VarType.UINT8
elif dtype == 21:
return core.VarDesc.VarType.INT8
elif dtype == np.complex64:
_dtype_map = {
0: core.VarDesc.VarType.BOOL,
1: core.VarDesc.VarType.INT16,
2: core.VarDesc.VarType.INT32,
3: core.VarDesc.VarType.INT64,
4: core.VarDesc.VarType.FP16,
5: core.VarDesc.VarType.FP32,
6: core.VarDesc.VarType.FP64,
20: core.VarDesc.VarType.UINT8,
21: core.VarDesc.VarType.INT8,
22: core.VarDesc.VarType.BF16,
}
if dtype in _dtype_map.keys():
return _dtype_map[dtype]
else:
raise ValueError("Not supported dtype %s" % dtype)


Expand Down