Skip to content

Commit 9d97bf5

Browse files
committed
cleanup unused type ignore
1 parent 7bc0770 commit 9d97bf5

File tree

13 files changed

+34
-34
lines changed

13 files changed

+34
-34
lines changed

python/paddle/base/framework.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ def backward(self, retain_graph=False):
19691969
>>> import paddle
19701970
>>> paddle.disable_static()
19711971
1972-
>>> x = np.ones([2, 2], np.float32) # type: ignore[var-annotated]
1972+
>>> x = np.ones([2, 2], np.float32)
19731973
>>> inputs = []
19741974
>>> for _ in range(10):
19751975
... tmp = paddle.to_tensor(x)
@@ -2013,7 +2013,7 @@ def gradient(self):
20132013
>>> import numpy as np
20142014
20152015
>>> # example1: return ndarray
2016-
>>> x = np.ones([2, 2], np.float32) # type: ignore[var-annotated]
2016+
>>> x = np.ones([2, 2], np.float32)
20172017
>>> with base.dygraph.guard():
20182018
... inputs2 = []
20192019
... for _ in range(10):
@@ -2062,7 +2062,7 @@ def clear_gradient(self):
20622062
>>> import paddle.base as base
20632063
>>> import numpy as np
20642064
2065-
>>> x = np.ones([2, 2], np.float32) # type: ignore[var-annotated]
2065+
>>> x = np.ones([2, 2], np.float32)
20662066
>>> inputs2 = []
20672067
>>> for _ in range(10):
20682068
>>> tmp = paddle.to_tensor(x)

python/paddle/base/layers/math_op_patch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def astype(self, dtype):
358358
>>> import paddle
359359
>>> import numpy as np
360360
361-
>>> x = np.ones([2, 2], np.float32) # type: ignore[var-annotated]
361+
>>> x = np.ones([2, 2], np.float32)
362362
>>> with base.dygraph.guard():
363363
... original_variable = paddle.to_tensor(x)
364364
... print("original var's dtype is: {}, numpy dtype is {}".format(original_variable.dtype, original_variable.numpy().dtype))

python/paddle/distributed/parallel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class DataParallel(Layer):
348348
... model = paddle.DataParallel(model)
349349
... opt = paddle.optimizer.SGD(learning_rate=0.01, parameters=model.parameters())
350350
... for step in range(10):
351-
... x_data = numpy.random.randn(2, 2).astype(numpy.float32) # type: ignore[var-annotated]
351+
... x_data = numpy.random.randn(2, 2).astype(numpy.float32)
352352
... x = paddle.to_tensor(x_data)
353353
... x.stop_gradient = False
354354
... # step 1 : skip gradient synchronization by 'no_sync'

python/paddle/incubate/optimizer/lbfgs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ class LBFGS(Optimizer):
9393
9494
>>> paddle.disable_static()
9595
>>> np.random.seed(0)
96-
>>> np_w = np.random.rand(1).astype(np.float32) # type: ignore[var-annotated]
97-
>>> np_x = np.random.rand(1).astype(np.float32) # type: ignore[var-annotated]
96+
>>> np_w = np.random.rand(1).astype(np.float32)
97+
>>> np_x = np.random.rand(1).astype(np.float32)
9898
99-
>>> inputs = [np.random.rand(1).astype(np.float32) for i in range(10)] # type: ignore[var-annotated]
99+
>>> inputs = [np.random.rand(1).astype(np.float32) for i in range(10)]
100100
>>> # y = 2x
101101
>>> targets = [2 * x for x in inputs]
102102

python/paddle/optimizer/lbfgs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ class LBFGS(Optimizer):
396396
397397
>>> paddle.disable_static()
398398
>>> np.random.seed(0)
399-
>>> np_w = np.random.rand(1).astype(np.float32) # type: ignore[var-annotated]
400-
>>> np_x = np.random.rand(1).astype(np.float32) # type: ignore[var-annotated]
399+
>>> np_w = np.random.rand(1).astype(np.float32)
400+
>>> np_x = np.random.rand(1).astype(np.float32)
401401
402-
>>> inputs = [np.random.rand(1).astype(np.float32) for i in range(10)] # type: ignore[var-annotated]
402+
>>> inputs = [np.random.rand(1).astype(np.float32) for i in range(10)]
403403
>>> # y = 2x
404404
>>> targets = [2 * x for x in inputs]
405405

python/paddle/static/input.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def data(
110110
111111
# In this example, we will feed x and y with np-ndarray "1"
112112
# and fetch z, like implementing "1 + 1 = 2" in PaddlePaddle
113-
>>> feed_data = np.ones(shape=[3, 2, 1], dtype=np.float32) # type: ignore[var-annotated]
113+
>>> feed_data = np.ones(shape=[3, 2, 1], dtype=np.float32)
114114
115115
>>> exe = paddle.static.Executor(paddle.framework.CPUPlace())
116116
>>> out = exe.run(paddle.static.default_main_program(),
@@ -308,7 +308,7 @@ def from_numpy(
308308
>>> import numpy as np
309309
>>> from paddle.static import InputSpec
310310
311-
>>> x = np.ones([2, 2], np.float32) # type: ignore[var-annotated]
311+
>>> x = np.ones([2, 2], np.float32)
312312
>>> x_spec = InputSpec.from_numpy(x, name='x')
313313
>>> print(x_spec)
314314
InputSpec(shape=(2, 2), dtype=paddle.float32, name=x, stop_gradient=False)

python/paddle/static/io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def load_inference_model(
900900
901901
>>> [inference_program, feed_target_names, fetch_targets] = (
902902
... paddle.static.load_inference_model(path_prefix, exe))
903-
>>> tensor_img = np.array(np.random.random((64, 784)), dtype=np.float32) # type: ignore[var-annotated]
903+
>>> tensor_img = np.array(np.random.random((64, 784)), dtype=np.float32)
904904
>>> results = exe.run(inference_program,
905905
... feed={feed_target_names[0]: tensor_img},
906906
... fetch_list=fetch_targets)

python/paddle/static/nn/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ def embedding(
35783578
>>> exe = paddle.static.Executor(place)
35793579
>>> exe.run(paddle.static.default_startup_program())
35803580
3581-
>>> x = np.array([[7, 2, 4, 5],[4, 3, 2, 9]], dtype=np.int64) # type: ignore[var-annotated]
3581+
>>> x = np.array([[7, 2, 4, 5],[4, 3, 2, 9]], dtype=np.int64)
35823582
>>> out, = exe.run(paddle.static.default_main_program(), feed={'x':x}, fetch_list=[output])
35833583
>>> print(out)
35843584
[[[1. 1. 1.]

python/paddle/static/nn/static_pylayer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def static_pylayer(forward_fn, inputs, backward_fn=None, name=None):
335335
... data_grad = paddle.static.gradients([ret], data)[0]
336336
337337
>>> exe.run(start_program)
338-
>>> x = np.array([[1.0, 2.0, 3.0, 4.0, 5.0]], dtype=np.float32) # type: ignore[var-annotated]
338+
>>> x = np.array([[1.0, 2.0, 3.0, 4.0, 5.0]], dtype=np.float32)
339339
>>> x, x_grad, y = exe.run(
340340
... main_program,
341341
... feed={"X": x},

python/paddle/static/pir_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ def load_inference_model_pir(path_prefix, executor, **kwargs):
840840
841841
>>> [inference_program, feed_target_names, fetch_targets] = (
842842
... paddle.static.load_inference_model(path_prefix, exe))
843-
>>> tensor_img = np.array(np.random.random((64, 784)), dtype=np.float32) # type: ignore[var-annotated]
843+
>>> tensor_img = np.array(np.random.random((64, 784)), dtype=np.float32)
844844
>>> results = exe.run(inference_program,
845845
... feed={feed_target_names[0]: tensor_img},
846846
... fetch_list=fetch_targets)

python/paddle/tensor/attribute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def shape(input: Tensor) -> Tensor:
102102
>>> exe = paddle.static.Executor(paddle.CPUPlace())
103103
>>> exe.run(paddle.static.default_startup_program())
104104
105-
>>> img = np.ones((3, 100, 100)).astype(np.float32) # type: ignore[var-annotated]
105+
>>> img = np.ones((3, 100, 100)).astype(np.float32)
106106
107107
>>> res = exe.run(paddle.static.default_main_program(), feed={'x':img}, fetch_list=[output])
108108
>>> print(res)

python/paddle/tensor/creation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,7 @@ def assign(x: TensorLike, output: paddle.Tensor | None = None) -> paddle.Tensor:
26452645
[2.5 2.5]]
26462646
>>> array = np.array([[1, 1], [3, 4], [1, 3]]).astype(
26472647
... np.int64
2648-
... ) # type: ignore[var-annotated]
2648+
... )
26492649
>>> result1 = paddle.zeros(shape=[3, 3], dtype='float32')
26502650
>>> paddle.assign(array, result1)
26512651
>>> print(result1.numpy())

python/paddle/vision/transforms/transforms.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class ToTensor(BaseTransform[_InputT, "Tensor"]):
387387
>>> img_arr = ((paddle.rand((4, 5, 3)) * 255.).astype('uint8')).numpy()
388388
>>> fake_img = Image.fromarray(img_arr)
389389
>>> transform = T.ToTensor()
390-
>>> tensor = transform(fake_img) # type: ignore[call-overload]
390+
>>> tensor = transform(fake_img)
391391
>>> print(tensor.shape)
392392
[3, 4, 5]
393393
>>> print(tensor.dtype)
@@ -457,11 +457,11 @@ class Resize(BaseTransform[_InputT, _RetT]):
457457
458458
>>> fake_img = Image.fromarray((np.random.rand(256, 300, 3) * 255.).astype(np.uint8))
459459
>>> transform = Resize(size=224)
460-
>>> converted_img = transform(fake_img) # type: ignore[call-overload]
460+
>>> converted_img = transform(fake_img)
461461
>>> print(converted_img.size)
462462
(262, 224)
463463
>>> transform = Resize(size=(200,150))
464-
>>> converted_img = transform(fake_img) # type: ignore[call-overload]
464+
>>> converted_img = transform(fake_img)
465465
>>> print(converted_img.size)
466466
(150, 200)
467467
"""
@@ -530,7 +530,7 @@ class RandomResizedCrop(BaseTransform[_InputT, _RetT]):
530530
531531
>>> transform = RandomResizedCrop(224)
532532
>>> fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))
533-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
533+
>>> fake_img = transform(fake_img)
534534
>>> print(fake_img.size)
535535
(224, 224)
536536
@@ -736,7 +736,7 @@ class CenterCrop(BaseTransform[_InputT, _RetT]):
736736
737737
>>> transform = CenterCrop(224)
738738
>>> fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))
739-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
739+
>>> fake_img = transform(fake_img)
740740
>>> print(fake_img.size)
741741
(224, 224)
742742
@@ -918,7 +918,7 @@ class Normalize(BaseTransform[_InputT, _RetT]):
918918
... data_format='HWC')
919919
...
920920
>>> fake_img = paddle.rand([300,320,3]).numpy() * 255.
921-
>>> fake_img = normalize(fake_img) # type: ignore[call-overload]
921+
>>> fake_img = normalize(fake_img)
922922
>>> print(fake_img.shape)
923923
(300, 320, 3)
924924
>>> print(fake_img.max(), fake_img.min())
@@ -985,7 +985,7 @@ class Transpose(BaseTransform[_InputT, _RetT]):
985985
986986
>>> transform = Transpose()
987987
>>> fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))
988-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
988+
>>> fake_img = transform(fake_img)
989989
>>> print(fake_img.shape)
990990
(3, 300, 320)
991991
@@ -1042,7 +1042,7 @@ class BrightnessTransform(BaseTransform[_InputT, _RetT]):
10421042
>>> print(fake_img.load()[1,1]) # type: ignore[index]
10431043
(60, 169, 34)
10441044
>>> # doctest: +SKIP('random sample in Brightness function')
1045-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1045+
>>> fake_img = transform(fake_img)
10461046
>>> print(fake_img.load()[1,1])
10471047
(68, 192, 38)
10481048
@@ -1089,7 +1089,7 @@ class ContrastTransform(BaseTransform[_InputT, _RetT]):
10891089
10901090
>>> transform = ContrastTransform(0.4)
10911091
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
1092-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1092+
>>> fake_img = transform(fake_img)
10931093
>>> print(fake_img.size)
10941094
(224, 224)
10951095
@@ -1138,7 +1138,7 @@ class SaturationTransform(BaseTransform[_InputT, _RetT]):
11381138
11391139
>>> transform = SaturationTransform(0.4)
11401140
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
1141-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1141+
>>> fake_img = transform(fake_img)
11421142
>>> print(fake_img.size)
11431143
(224, 224)
11441144
"""
@@ -1184,7 +1184,7 @@ class HueTransform(BaseTransform[_InputT, _RetT]):
11841184
11851185
>>> transform = HueTransform(0.4)
11861186
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
1187-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1187+
>>> fake_img = transform(fake_img)
11881188
>>> print(fake_img.size)
11891189
(224, 224)
11901190
@@ -1239,7 +1239,7 @@ class ColorJitter(BaseTransform[_InputT, _RetT]):
12391239
12401240
>>> transform = ColorJitter(0.4, 0.4, 0.4, 0.4)
12411241
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
1242-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1242+
>>> fake_img = transform(fake_img)
12431243
>>> print(fake_img.size)
12441244
(224, 224)
12451245
@@ -1480,7 +1480,7 @@ class Pad(BaseTransform[_InputT, _RetT]):
14801480
14811481
>>> transform = Pad(2)
14821482
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
1483-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1483+
>>> fake_img = transform(fake_img)
14841484
>>> print(fake_img.size)
14851485
(228, 228)
14861486
"""
@@ -1778,7 +1778,7 @@ class RandomRotation(BaseTransform[_InputT, _RetT]):
17781778
17791779
>>> transform = RandomRotation(90)
17801780
>>> fake_img = Image.fromarray((np.random.rand(200, 150, 3) * 255.).astype(np.uint8))
1781-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
1781+
>>> fake_img = transform(fake_img)
17821782
>>> print(fake_img.size)
17831783
(150, 200)
17841784
"""
@@ -2012,7 +2012,7 @@ class Grayscale(BaseTransform[_InputT, _RetT]):
20122012
20132013
>>> transform = Grayscale()
20142014
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
2015-
>>> fake_img = transform(fake_img) # type: ignore[call-overload]
2015+
>>> fake_img = transform(fake_img)
20162016
>>> print(np.array(fake_img).shape)
20172017
(224, 224)
20182018
"""

0 commit comments

Comments
 (0)