We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdbef41 commit 914454eCopy full SHA for 914454e
tests/snippets/builtin_complex.py
@@ -57,6 +57,13 @@
57
assert complex(1) ** 2 == 1
58
assert 2 ** complex(2) == 4
59
60
+# __pos__
61
+
62
+assert +complex(0, 1) == complex(0, 1)
63
+assert +complex(1, 0) == complex(1, 0)
64
+assert +complex(1, -1) == complex(1, -1)
65
+assert +complex(0, 0) == complex(0, 0)
66
67
# __neg__
68
69
assert -complex(1, -1) == complex(-1, 1)
vm/src/obj/objcomplex.rs
@@ -183,6 +183,11 @@ impl PyComplex {
183
self.divmod(other, vm)
184
}
185
186
+ #[pymethod(name = "__pos__")]
187
+ fn pos(&self) -> Complex64 {
188
+ self.value
189
+ }
190
191
#[pymethod(name = "__neg__")]
192
fn neg(&self) -> Complex64 {
193
-self.value
0 commit comments