Package org.python.core

# Class PyComplex

java.lang.Object
org.python.core.PyObject
org.python.core.PyComplex

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `PyComplexDerived`

public class PyComplex extends PyObject
A builtin python complex number

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class org.python.core.PyObject

`PyObject.ConversionException`

## Field Summary

Fields
Modifier and Type
Field
Description
`double`
`imag`
`static final PyComplex`
`Inf`
`static final PyComplex`
`NaN`
`double`
`real`
`static final PyType`
`TYPE`

### Fields inherited from class org.python.core.PyObject

`gcMonitorGlobal`

## Constructor Summary

Constructors
Constructor
Description
`PyComplex(double r)`
`PyComplex(double r, double i)`
`PyComplex(PyType subtype, double r, double i)`

## Method Summary

Modifier and Type
Method
Description
`PyObject`
`__abs__()`
Equivalent to the standard Python __abs__ method.
`PyObject`
`__add__(PyObject right)`
Equivalent to the standard Python __add__ method.
`int`
`__cmp__(PyObject other)`
Equivalent to the standard Python __cmp__ method.
`Object`
`__coerce_ex__(PyObject other)`
Implements numeric coercion
`PyComplex`
`__complex__()`
Equivalent to the standard Python __complex__ method.
`PyObject`
`__div__(PyObject right)`
Equivalent to the standard Python __div__ method
`PyObject`
`__divmod__(PyObject right)`
Equivalent to the standard Python __divmod__ method
`PyObject`
`__eq__(PyObject other)`
Equivalent to the standard Python __eq__ method.
`PyFloat`
`__float__()`
Equivalent to the standard Python __float__ method.
`PyObject`
`__floordiv__(PyObject right)`
Equivalent to the standard Python __floordiv__ method
`PyObject`
`__format__(PyObject formatSpec)`
`PyObject`
`__ge__(PyObject other)`
Equivalent to the standard Python __ge__ method.
`PyTuple`
`__getnewargs__()`
`PyObject`
`__gt__(PyObject other)`
Equivalent to the standard Python __gt__ method.
`PyObject`
`__int__()`
Equivalent to the standard Python __int__ method.
`PyObject`
`__invert__()`
Equivalent to the standard Python __invert__ method.
`PyObject`
`__le__(PyObject other)`
Equivalent to the standard Python __le__ method.
`PyObject`
`__long__()`
Equivalent to the standard Python __long__ method.
`PyObject`
`__lt__(PyObject other)`
Equivalent to the standard Python __lt__ method.
`PyObject`
`__mod__(PyObject right)`
Equivalent to the standard Python __mod__ method
`PyObject`
`__mul__(PyObject right)`
Equivalent to the standard Python __mul__ method.
`PyObject`
`__ne__(PyObject other)`
Equivalent to the standard Python __ne__ method.
`PyObject`
`__neg__()`
Equivalent to the standard Python __neg__ method.
`boolean`
`__nonzero__()`
Equivalent to the standard Python __nonzero__ method.
`PyObject`
`__pos__()`
Equivalent to the standard Python __pos__ method.
`PyObject`
`__pow__(PyObject right, PyObject modulo)`
Implements the three argument power function.
`PyObject`
`__radd__(PyObject left)`
Equivalent to the standard Python __radd__ method.
`PyObject`
`__rdiv__(PyObject left)`
Equivalent to the standard Python __rdiv__ method
`PyObject`
`__rdivmod__(PyObject left)`
Equivalent to the standard Python __rdivmod__ method
`PyString`
`__repr__()`
Equivalent to the standard Python `__repr__` method.
`PyObject`
`__rfloordiv__(PyObject left)`
Equivalent to the standard Python __rfloordiv__ method
`PyObject`
`__rmod__(PyObject left)`
Equivalent to the standard Python __rmod__ method
`PyObject`
`__rmul__(PyObject left)`
Equivalent to the standard Python __rmul__ method.
`PyObject`
`__rpow__(PyObject left)`
Equivalent to the standard Python __rpow__ method
`PyObject`
`__rsub__(PyObject left)`
Equivalent to the standard Python __rsub__ method
`PyObject`
`__rtruediv__(PyObject left)`
Equivalent to the standard Python __rtruediv__ method
`PyString`
`__str__()`
Equivalent to the standard Python __str__ method.
`PyObject`
`__sub__(PyObject right)`
Equivalent to the standard Python __sub__ method
`Object`
`__tojava__(Class<?> c)`
Equivalent to the Jython __tojava__ method.
`PyObject`
`__truediv__(PyObject right)`
Equivalent to the standard Python __truediv__ method
`static PyObject`
`_pow(PyComplex value, PyComplex right)`
`static PyObject`
`complex_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)`
`PyComplex`
`conjugate()`
Equivalent to the standard Python conjugate method.
`final PyFloat`
`getImag()`
`final PyFloat`
`getReal()`
`int`
`hashCode()`
`boolean`
`isNumberType()`
`String`
`toString()`
`static String`
`toString(double value)`

### Methods inherited from class org.python.core.PyObject

`__and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __contains__, __delattr__, __delattr__, __delete__, __delitem__, __delitem__, __delslice__, __delslice__, __dir__, __ensure_finalizer__, __findattr__, __findattr__, __findattr_ex__, __finditem__, __finditem__, __finditem__, __get__, __getattr__, __getattr__, __getitem__, __getitem__, __getslice__, __getslice__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __ior__, __ipow__, __irshift__, __isub__, __iter__, __iternext__, __itruediv__, __ixor__, __len__, __lshift__, __not__, __oct__, __or__, __pow__, __rand__, __reduce__, __reduce_ex__, __reduce_ex__, __rlshift__, __ror__, __rrshift__, __rshift__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setitem__, __setitem__, __setslice__, __setslice__, __trunc__, __unicode__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _iadd, _iand, _idiv, _idivmod, _ifloordiv, _ilshift, _imod, _imul, _in, _ior, _ipow, _irshift, _is, _isnot, _isub, _itruediv, _ixor, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asDouble, asIndex, asIndex, asInt, asInt, asIterable, asLong, asLong, asName, asName, asString, asString, asStringOrNull, asStringOrNull, bit_length, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getType, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, isInteger, isMappingType, isSequenceType, noAttributeError, object___subclasshook__, readonlyAttributeError, setDict, setType`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### TYPE

public static final PyType TYPE

### Inf

public static final PyComplex Inf

### NaN

public static final PyComplex NaN

### real

public double real

### imag

public double imag

## Constructor Details

### PyComplex

public PyComplex(PyType subtype, double r, double i)

### PyComplex

public PyComplex(double r, double i)

### PyComplex

public PyComplex(double r)

## Method Details

### complex_new

public static PyObject complex_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)

### getReal

public final PyFloat getReal()

### getImag

public final PyFloat getImag()

### toString

public static String toString(double value)

### toString

public String toString()

Overrides:
  `toString` in class `PyObject`

### __str__

public PyString __str__()
Description copied from class: `PyObject`
Equivalent to the standard Python __str__ method. The default implementation (in `PyObject`) calls `PyObject.__repr__()`, making it unnecessary to override `__str__` in sub-classes of `PyObject` where both forms are the same. A common choice is to provide the same implementation to `__str__` and `toString`, for consistency in the printed form of objects between Python and Java.

Overrides:
  `__str__` in class `PyObject`

### __repr__

public PyString __repr__()
Description copied from class: `PyObject`
Equivalent to the standard Python `__repr__` method. Each sub-class of `PyObject` is likely to re-define this method to provide for its own reproduction.

Overrides:
  `__repr__` in class `PyObject`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `PyObject`

### __nonzero__

public boolean __nonzero__()
Description copied from class: `PyObject`
Equivalent to the standard Python __nonzero__ method. Returns whether of not a given `PyObject` is considered true.

Overrides:
  `__nonzero__` in class `PyObject`

### __cmp__

public int __cmp__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __cmp__ method.

Overrides:
  `__cmp__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  -1 if `this<o`; 0 if `this==o`; +1 if `this>o`; -2 if no comparison is implemented

### __eq__

public PyObject __eq__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __eq__ method.

Overrides:
  `__eq__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __ne__

public PyObject __ne__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __ne__ method.

Overrides:
  `__ne__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __ge__

public PyObject __ge__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __ge__ method.

Overrides:
  `__ge__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __gt__

public PyObject __gt__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __gt__ method.

Overrides:
  `__gt__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __le__

public PyObject __le__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __le__ method.

Overrides:
  `__le__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __lt__

public PyObject __lt__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __lt__ method.

Overrides:
  `__lt__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __coerce_ex__

public Object __coerce_ex__(PyObject other)
Description copied from class: `PyObject`
Implements numeric coercion

Overrides:
  `__coerce_ex__` in class `PyObject`
Parameters:
  `other` - the other object involved in the coercion
Returns:
  null if coercion is not implemented Py.None if coercion was not possible a single PyObject to use to replace o if this is unchanged; or a PyObject[2] consisting of replacements for this and o.

### __add__

public PyObject __add__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __add__ method.

Overrides:
  `__add__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the add, or null if this operation is not defined.

### __radd__

public PyObject __radd__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __radd__ method.

Overrides:
  `__radd__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the add, or null if this operation is not defined.

### __sub__

public PyObject __sub__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __sub__ method

Overrides:
  `__sub__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the sub, or null if this operation is not defined

### __rsub__

public PyObject __rsub__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rsub__ method

Overrides:
  `__rsub__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the sub, or null if this operation is not defined.

### __mul__

public PyObject __mul__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __mul__ method.

Overrides:
  `__mul__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined

### __rmul__

public PyObject __rmul__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rmul__ method.

Overrides:
  `__rmul__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined.

### __div__

public PyObject __div__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __div__ method

Overrides:
  `__div__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the div, or null if this operation is not defined

### __rdiv__

public PyObject __rdiv__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rdiv__ method

Overrides:
  `__rdiv__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the div, or null if this operation is not defined.

### __floordiv__

public PyObject __floordiv__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __floordiv__ method

Overrides:
  `__floordiv__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the floordiv, or null if this operation is not defined

### __rfloordiv__

public PyObject __rfloordiv__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rfloordiv__ method

Overrides:
  `__rfloordiv__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the floordiv, or null if this operation is not defined.

### __tojava__

public Object __tojava__(Class<?> c)
Description copied from class: `PyObject`
Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object `Py.NoConversion` if this `PyObject` can not be converted to the desired Java class.

Overrides:
  `__tojava__` in class `PyObject`
Parameters:
  `c` - the Class to convert this `PyObject` to.

### __truediv__

public PyObject __truediv__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __truediv__ method

Overrides:
  `__truediv__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the truediv, or null if this operation is not defined

### __rtruediv__

public PyObject __rtruediv__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rtruediv__ method

Overrides:
  `__rtruediv__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the truediv, or null if this operation is not defined.

### __mod__

public PyObject __mod__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __mod__ method

Overrides:
  `__mod__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mod, or null if this operation is not defined

### __rmod__

public PyObject __rmod__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rmod__ method

Overrides:
  `__rmod__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the mod, or null if this operation is not defined.

### __divmod__

public PyObject __divmod__(PyObject right)
Description copied from class: `PyObject`
Equivalent to the standard Python __divmod__ method

Overrides:
  `__divmod__` in class `PyObject`
Parameters:
  `right` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the divmod, or null if this operation is not defined

### __rdivmod__

public PyObject __rdivmod__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rdivmod__ method

Overrides:
  `__rdivmod__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the divmod, or null if this operation is not defined.

### __pow__

public PyObject __pow__(PyObject right, PyObject modulo)
Description copied from class: `PyObject`
Implements the three argument power function.

Overrides:
  `__pow__` in class `PyObject`
Parameters:
  `right` - the power to raise this number to.
  `modulo` - the modulus to perform this operation in or null if no modulo is to be used
Returns:
  this object raised to the given power in the given modulus

### __rpow__

public PyObject __rpow__(PyObject left)
Description copied from class: `PyObject`
Equivalent to the standard Python __rpow__ method

Overrides:
  `__rpow__` in class `PyObject`
Parameters:
  `left` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the pow, or null if this operation is not defined.

### _pow

public static PyObject _pow(PyComplex value, PyComplex right)

### __neg__

public PyObject __neg__()
Description copied from class: `PyObject`
Equivalent to the standard Python __neg__ method.

Overrides:
  `__neg__` in class `PyObject`
Returns:
  -this.

### __pos__

public PyObject __pos__()
Description copied from class: `PyObject`
Equivalent to the standard Python __pos__ method.

Overrides:
  `__pos__` in class `PyObject`
Returns:
  +this.

### __invert__

public PyObject __invert__()
Description copied from class: `PyObject`
Equivalent to the standard Python __invert__ method.

Overrides:
  `__invert__` in class `PyObject`
Returns:
  ~this.

### __abs__

public PyObject __abs__()
Description copied from class: `PyObject`
Equivalent to the standard Python __abs__ method.

Overrides:
  `__abs__` in class `PyObject`
Returns:
  abs(this).

### __int__

public PyObject __int__()
Description copied from class: `PyObject`
Equivalent to the standard Python __int__ method. Should only be overridden by numeric objects that can be reasonably coerced into an integer.

Overrides:
  `__int__` in class `PyObject`
Returns:
  an integer corresponding to the value of this object.

### __long__

public PyObject __long__()
Description copied from class: `PyObject`
Equivalent to the standard Python __long__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python long.

Overrides:
  `__long__` in class `PyObject`
Returns:
  a PyLong or PyInteger corresponding to the value of this object.

### __float__

public PyFloat __float__()
Description copied from class: `PyObject`
Equivalent to the standard Python __float__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python float.

Overrides:
  `__float__` in class `PyObject`
Returns:
  a float corresponding to the value of this object.

### __complex__

public PyComplex __complex__()
Description copied from class: `PyObject`
Equivalent to the standard Python __complex__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python complex number.

Overrides:
  `__complex__` in class `PyObject`
Returns:
  a complex number corresponding to the value of this object.

### conjugate

public PyComplex conjugate()
Description copied from class: `PyObject`
Equivalent to the standard Python conjugate method. Should only be overridden by numeric objects that can calculate a complex conjugate.

Overrides:
  `conjugate` in class `PyObject`
Returns:
  the complex conjugate.

### __getnewargs__

public PyTuple __getnewargs__()

Overrides:
  `__getnewargs__` in class `PyObject`

### __format__

public PyObject __format__(PyObject formatSpec)

Overrides:
  `__format__` in class `PyObject`

### isNumberType

public boolean isNumberType()

Overrides:
  `isNumberType` in class `PyObject`