Skip to content

Commit 4a598d0

Browse files
committed
Add float.imag, float.conjugate
1 parent bb878a3 commit 4a598d0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/snippets/floats.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@
140140
assert 3 ** 2.0 == 9.0
141141

142142
assert (1.7).real == 1.7
143+
assert (1.7).imag == 0.0
144+
assert (1.7).conjugate() == 1.7
143145
assert (1.3).is_integer() == False
144146
assert (1.0).is_integer() == True
145147

vm/src/obj/objfloat.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ impl PyFloat {
364364
zelf
365365
}
366366

367+
#[pyproperty(name = "imag")]
368+
fn imag(&self, _vm: &VirtualMachine) -> f64 {
369+
0.0f64
370+
}
371+
372+
#[pymethod(name = "conjugate")]
373+
fn conjugate(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyFloatRef {
374+
zelf
375+
}
376+
367377
#[pymethod(name = "is_integer")]
368378
fn is_integer(&self, _vm: &VirtualMachine) -> bool {
369379
let v = self.value;

0 commit comments

Comments
 (0)