Number

class cake.Number(value: Any, check_value_attr: bool = True, base_type: Callable = <class 'float'>, return_me: Callable = Ellipsis, return_handler: Optional[Callable] = None, *args, **kwargs)

Base class for creating digits, unknowns etc.

If creating an unknown, its best to use the Unknown class instead of this . Mainly due to the handling of an unknown is implemented in this class

An unknown should only be used when the value is not known, meaning it can be anything. Else implement the Range class.

For Quaternion’s, the value can be a tuple, or the class itself.

Parameters
  • value (Any) – The value that the class holds, can be a letter, digit, float etc.

  • check_value_attr (bool) – When a user preforms an arithmetic action it will check the other argument for the value attribute If found, it replaces the argument with that value, else returns the original argument

  • base_type (Any]) – A function or class, which is used to convert the input value to, defaults to float

  • return_me (typing.Callable[[..., ], typing.Any]) – A function or class which is returned when an arithmetic operator is used on the class. This is different from base_type as this returns the specified class as opposed to just converting the input to specific type.

  • return_handler (typing.Callable[[..., ], typing.Any]) –

    skips the default return class and calls this method with the following arguments, in the same order.

    Result
    Check Value Attribute
    Type
    Current Return Class
    args
    kwargs
    

*args: Any

Additional arguments which you may supply when using arithmetic operators such as +

**kwargs: Any

Additional keyword arguments which you may supply when using arithmetic operators such as +

Returns

Return type

A number class which can handle all python operators

Dunder Methods

__call__(O)

Implementation of chaining, Action formed is multiplication

__abs__()

__add__(O)

__sub__(O)

__neg__()

__pos__()

__mul__(other)

__ceil__()

__truediv__(O)

__floordiv__(O)

__mod__(O)

__divmod__(O)

__pow__(O)

__lshift__(O)

__rshift__(O)

__and__(O)

__xor__(O)

__or__(O)

__lt__(O)

Return self<value.

__le__(O)

Return self<=value.

__gt__(O)

Return self>value.

__ge__(O)

Return self>=value.

__eq__(O)

Return self==value.

__ne__(O)

Return self!=value.

__bool__()

__int__()

__float__()

__complex__()

__str__()

Return str(self).

get_value(self, other, check_value_attr, *args, **kwargs)

Get the value of other by checking if O has either, a get_value method or a value attr.

Note

If O is None, O becomes N

property type: Callable

Returns the value type which was set when intialising the class, this will always return the actual class which you was set.

This value is overridable

property value: Any

Returns the value supplied when initialising the class, if it has been converted to the provided type, then that value is returned instead.

This is overridable and deletable, if deleted value is set to 0.