complex type: Added __doc__
@@ -8,8 +8,18 @@ use num_complex::Complex64;
pub fn init(context: &PyContext) {
let complex_type = &context.complex_type;
+
+ let complex_doc =
+ "Create a complex number from a real part and an optional imaginary part.\n\n\
+ This is equivalent to (real + imag*1j) where imag defaults to 0.";
+
context.set_attr(&complex_type, "__add__", context.new_rustfunc(complex_add));
context.set_attr(&complex_type, "__new__", context.new_rustfunc(complex_new));
+ context.set_attr(
+ &complex_type,
+ "__doc__",
+ context.new_str(complex_doc.to_string()),
+ );
context.set_attr(
&complex_type,
"__repr__",
