MCPcopy Create free account
hub / github.com/ipython/traitlets / Complex

Class Complex

traitlets/traitlets.py:2832–2851  ·  view source on GitHub ↗

A trait for complex numbers.

Source from the content-addressed store, hash-verified

2830
2831
2832class Complex(TraitType[complex, t.Union[complex, float, int]]):
2833 """A trait for complex numbers."""
2834
2835 default_value = 0.0 + 0.0j
2836 info_text = "a complex number"
2837
2838 def validate(self, obj: t.Any, value: t.Any) -> complex | None:
2839 if isinstance(value, complex):
2840 return value
2841 if isinstance(value, (float, int)):
2842 return complex(value)
2843 self.error(obj, value)
2844
2845 def from_string(self, s: str) -> complex | None:
2846 if self.allow_none and s == "None":
2847 return None
2848 return complex(s)
2849
2850 def subclass_init(self, cls: type[t.Any]) -> None:
2851 pass # fully opt out of instance_init
2852
2853
2854class CComplex(Complex, TraitType[complex, t.Any]):

Callers 1

ComplexTraitClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…