inversion_ideas.base.Multiplier#

class inversion_ideas.base.Multiplier(value, *, mutable=False)#

Multiplier hyperparameter.

Wraps a single float that can be used as a multiplier for objective functions.

Parameters:
valuefloat

Value of the wrapped multiplier.

mutablebool, optional

If False, the wrapped value is immutable, i.e. we cannot change it through public properties and methods. If True, the wrapped value is mutable and can be modified.

Attributes

imag

Real numbers have no imaginary component.

mutable

Mutable flag.

real

Real numbers are their real component.

value

Wrapped multiplier.

Methods

conjugate()

Conjugate is a no-op for Reals.

Examples

A wrapped multiplier behaves like any regular float:

>>> beta = Multiplier(5.0)
>>> print(beta)
Multiplier(5.0)
>>> 3 * beta
15.0

By default the multiplier is immutable, i.e. we cannot change the value thorugh public methods.

>>> beta *= 5
Traceback (most recent call last):
TypeError: ...
>>> beta.value = 10.0
Traceback (most recent call last):
TypeError: ...

We can make it mutable when defining the multiplier:

>>> beta = Multiplier(5.0, mutable=True)
>>> beta *= 5
>>> print(beta)
Multiplier(25.0)

Attributes#

Multiplier.imag#

Real numbers have no imaginary component.

Multiplier.mutable#

Mutable flag.

Multiplier.real#

Real numbers are their real component.

Multiplier.value#

Wrapped multiplier.

Methods#

Methods documentation

Multiplier.conjugate()#

Conjugate is a no-op for Reals.