Debian Codegraph @

tests/data/cases/preview_simplify_power_operator_hugging.py

raw
1 # flags: --preview
2 # This is a copy of `power_op_spacing.py`. Remove when `simplify_power_operator_hugging` becomes stable.
3
4 def function(**kwargs):
5 t = a**2 + b**3
6 return t ** 2
7
8
9 def function_replace_spaces(**kwargs):
10 t = a **2 + b** 3 + c ** 4
11
12
13 def function_dont_replace_spaces():
14 {**a, **b, **c}
15
16
17 a = 5**~4
18 b = 5 ** f()
19 c = -(5**2)
20 d = 5 ** f["hi"]
21 e = lazy(lambda **kwargs: 5)
22 f = f() ** 5
23 g = a.b**c.d
24 h = 5 ** funcs.f()
25 i = funcs.f() ** 5
26 j = super().name ** 5
27 k = [(2**idx, value) for idx, value in pairs]
28 l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
29 m = [([2**63], [1, 2**63])]
30 n = count <= 10**5
31 o = settings(max_examples=10**6)
32 p = {(k, k**2): v**2 for k, v in pairs}
33 q = [10**i for i in range(6)]
34 r = x**y
35 s = 1 ** 1
36 t = (
37 1
38 ** 1
39 **1
40 ** 1
41 )
42
43 a = 5.0**~4.0
44 b = 5.0 ** f()
45 c = -(5.0**2.0)
46 d = 5.0 ** f["hi"]
47 e = lazy(lambda **kwargs: 5)
48 f = f() ** 5.0
49 g = a.b**c.d
50 h = 5.0 ** funcs.f()
51 i = funcs.f() ** 5.0
52 j = super().name ** 5.0
53 k = [(2.0**idx, value) for idx, value in pairs]
54 l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
55 m = [([2.0**63.0], [1.0, 2**63.0])]
56 n = count <= 10**5.0
57 o = settings(max_examples=10**6.0)
58 p = {(k, k**2): v**2.0 for k, v in pairs}
59 q = [10.5**i for i in range(6)]
60 s = 1.0 ** 1.0
61 t = (
62 1.0
63 ** 1.0
64 **1.0
65 ** 1.0
66 )
67
68
69 # WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
70 if hasattr(view, "sum_of_weights"):
71 return np.divide( # type: ignore[no-any-return]
72 view.variance, # type: ignore[union-attr]
73 view.sum_of_weights, # type: ignore[union-attr]
74 out=np.full(view.sum_of_weights.shape, np.nan), # type: ignore[union-attr]
75 where=view.sum_of_weights**2 > view.sum_of_weights_squared, # type: ignore[union-attr]
76 )
77
78 return np.divide(
79 where=view.sum_of_weights_of_weight_long**2 > view.sum_of_weights_squared, # type: ignore
80 )
81
82
83 # output
84 # This is a copy of `power_op_spacing.py`. Remove when `simplify_power_operator_hugging` becomes stable.
85
86
87 def function(**kwargs):
88 t = a**2 + b**3
89 return t**2
90
91
92 def function_replace_spaces(**kwargs):
93 t = a**2 + b**3 + c**4
94
95
96 def function_dont_replace_spaces():
97 {**a, **b, **c}
98
99
100 a = 5**~4
101 b = 5 ** f()
102 c = -(5**2)
103 d = 5 ** f["hi"]
104 e = lazy(lambda **kwargs: 5)
105 f = f() ** 5
106 g = a.b**c.d
107 h = 5 ** funcs.f()
108 i = funcs.f() ** 5
109 j = super().name ** 5
110 k = [(2**idx, value) for idx, value in pairs]
111 l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
112 m = [([2**63], [1, 2**63])]
113 n = count <= 10**5
114 o = settings(max_examples=10**6)
115 p = {(k, k**2): v**2 for k, v in pairs}
116 q = [10**i for i in range(6)]
117 r = x**y
118 s = 1**1
119 t = 1**1**1**1
120
121 a = 5.0**~4.0
122 b = 5.0 ** f()
123 c = -(5.0**2.0)
124 d = 5.0 ** f["hi"]
125 e = lazy(lambda **kwargs: 5)
126 f = f() ** 5.0
127 g = a.b**c.d
128 h = 5.0 ** funcs.f()
129 i = funcs.f() ** 5.0
130 j = super().name ** 5.0
131 k = [(2.0**idx, value) for idx, value in pairs]
132 l = mod.weights_[0] == pytest.approx(0.95**100, abs=0.001)
133 m = [([2.0**63.0], [1.0, 2**63.0])]
134 n = count <= 10**5.0
135 o = settings(max_examples=10**6.0)
136 p = {(k, k**2): v**2.0 for k, v in pairs}
137 q = [10.5**i for i in range(6)]
138 s = 1.0**1.0
139 t = 1.0**1.0**1.0**1.0
140
141
142 # WE SHOULD DEFINITELY NOT EAT THESE COMMENTS (https://github.com/psf/black/issues/2873)
143 if hasattr(view, "sum_of_weights"):
144 return np.divide( # type: ignore[no-any-return]
145 view.variance, # type: ignore[union-attr]
146 view.sum_of_weights, # type: ignore[union-attr]
147 out=np.full(view.sum_of_weights.shape, np.nan), # type: ignore[union-attr]
148 where=view.sum_of_weights**2 > view.sum_of_weights_squared, # type: ignore[union-attr]
149 )
150
151 return np.divide(
152 where=view.sum_of_weights_of_weight_long**2 > view.sum_of_weights_squared, # type: ignore
153 )