mathmaker
0.6(alpha)
|
This class embedds Numbers & Strings into a basic object. More...
Public Member Functions | |
def | __init__ |
Constructor. | |
def | get_first_letter |
If the object is literal, returns the value. | |
def | get_has_been_rounded |
Returns the "has been rounded" state of the Value. | |
def | get_iteration_list |
Returns the list of elements to iter over. | |
def | get_minus_signs_nb |
Returns the number of minus signs in the object. | |
def | get_raw_value |
Returns the raw value contained in the Value. | |
def | get_sign |
Returns the sign of the Value. | |
def | get_unit |
Returns the unit of the Value. | |
def | set_has_been_rounded |
Sets the "has been rounded" state of the Value. | |
def | set_sign |
Set the sign of the object. | |
def | set_unit |
Set the unit of the Value. | |
def | set_opposite_sign |
Changes the sign of the object. | |
def | into_str |
Creates a string of the given object in the given ML. | |
def | evaluate |
Returns the value of a numeric Value. | |
def | calculate_next_step |
Returns None. | |
def | dbg_str |
Debugging method to print the Value. | |
def | __eq__ |
Compares two Values. | |
def | __len__ |
Returns the Value's length. | |
def | __hash__ |
Makes Values hashable (so, usable as dictionnary keys) | |
def | __mul__ |
Executes the multiplication with another object. | |
def | __add__ |
Executes the addition with another object. | |
def | substitute |
Uses the given lexicon to substitute literal Values in self. | |
def | sqrt |
Returns a Value containing the square root of self. | |
def | round |
Returns the value once rounded to the given precision. | |
def | digits_number |
Returns the number of digits of a numerical value. | |
def | needs_to_get_rounded |
Returns True/False depending on the need of the value to get rounded (for instance 2.68 doesn't need to get rounded if precision is HUNDREDTH or more, but needs it if it is less) | |
def | contains_a_rounded_number |
To check if this contains a rounded number... | |
def | contains_exactly |
Always False for a Value. | |
def | is_a_perfect_square |
True if the object contains a perfect square (integer or decimal) | |
def | is_an_integer |
True if the object contains an integer (numeric) | |
def | is_numeric |
True if the object only contains numeric objects. | |
def | is_literal |
True if the object only contains literal objects. | |
def | is_null |
True if the evaluated value of an object is null. | |
def | is_displ_as_a_single_1 |
True if the object can be displayed as a single 1. | |
def | is_displ_as_a_single_minus_1 |
True if the object can be displayed as a single -1. | |
def | is_displ_as_a_single_0 |
True if the object can be displayed as a single 0. | |
def | is_displ_as_a_single_numeric_Item |
True if the object is or only contains one numeric Item. | |
def | is_displ_as_a_single_int |
True if the object can be displayed as a single int. | |
Properties | |
raw_value | |
has_been_rounded | |
sign | |
unit |
This class embedds Numbers & Strings into a basic object.
It doesn't have any exponent field (always set to 1), so does not belong to Exponenteds. This is the only place where numbers are used directly. The Item class for instance, contains Values in its fields, not numbers. This to be sure any content of any field (even if only a simple number is to be saved in the field) can be tested & managed as an object in any other class than Value. Up from 2010/11/19, it is decided that all numeric Values will contain a Decimal.decimal number.
Definition at line 486 of file root_calculus.py.
def core.root_calculus.Value.__init__ | ( | self, | |
arg, | |||
options | |||
) |
Constructor.
arg | Number|String If the argument is not of one of these kinds, an exception will be raised. |
Definition at line 501 of file root_calculus.py.
References core.root_calculus.Value._has_been_rounded, core.root_calculus.Value._raw_value, core.base_calculus.Item._sign, core.root_calculus.Signed._sign, core.root_calculus.Value._sign, core.base_calculus.Function._sign, core.base_calculus.SquareRoot._sign, core.base_calculus.Quotient._sign, core.base_calculus.Fraction._sign, core.base_calculus.Item._unit, core.root_calculus.Value._unit, and core.base_calculus.Function._unit.
Referenced by core.root_calculus.Value.substitute().
def core.root_calculus.Value.__add__ | ( | self, | |
objct | |||
) |
Executes the addition with another object.
Definition at line 822 of file root_calculus.py.
References core.base_calculus.Item.raw_value, core.root_calculus.Value.raw_value, and core.base_calculus.Monomial.raw_value.
def core.root_calculus.Value.__eq__ | ( | self, | |
other_value | |||
) |
Compares two Values.
check if __eq__ shouldn't return +1 if value of self > objct
comparison directly with numbers...
(see alphabetical_order_cmp)
Definition at line 768 of file root_calculus.py.
References core.base_calculus.Item.raw_value, core.root_calculus.Value.raw_value, and core.base_calculus.Monomial.raw_value.
def core.root_calculus.Value.__len__ | ( | self | ) |
Returns the Value's length.
Reimplemented from core.root_calculus.Calculable.
Definition at line 785 of file root_calculus.py.
def core.root_calculus.Value.__mul__ | ( | self, | |
objct | |||
) |
Executes the multiplication with another object.
Definition at line 808 of file root_calculus.py.
References core.base_calculus.Item.raw_value, core.root_calculus.Value.raw_value, and core.base_calculus.Monomial.raw_value.
To check if this contains a rounded number...
Reimplemented from core.root_calculus.Evaluable.
Definition at line 970 of file root_calculus.py.
References core.root_calculus.Value.has_been_rounded.
def core.root_calculus.Value.contains_exactly | ( | self, | |
objct | |||
) |
Always False for a Value.
objct | The object to search for |
Reimplemented from core.root_calculus.Evaluable.
Definition at line 983 of file root_calculus.py.
def core.root_calculus.Value.evaluate | ( | self | ) |
Returns the value of a numeric Value.
Reimplemented from core.root_calculus.Evaluable.
Definition at line 731 of file root_calculus.py.
References core.root_calculus.Evaluable.is_numeric(), core.base_calculus.Item.is_numeric(), core.root_calculus.Value.is_numeric(), core.base_calculus.SquareRoot.is_numeric(), core.base_calculus.Operation.is_numeric(), core.calculus.Table.is_numeric(), core.base_calculus.Monomial.is_numeric(), core.base_calculus.Item.raw_value, core.root_calculus.Value.raw_value, and core.base_calculus.Monomial.raw_value.
Referenced by core.base_calculus.Product.calculate_next_step(), and core.base_calculus.Sum.is_null().
def core.root_calculus.Value.into_str | ( | self, | |
options | |||
) |
Creates a string of the given object in the given ML.
options | Any options |
Reimplemented from core.base.Printable.
Definition at line 690 of file root_calculus.py.
References core.root_calculus.Evaluable.get_first_letter(), core.base_calculus.Item.get_first_letter(), core.root_calculus.Value.get_first_letter(), core.base_calculus.CommutativeOperation.get_first_letter(), core.base_calculus.Monomial.get_first_letter(), core.root_calculus.Evaluable.is_numeric(), core.base_calculus.Item.is_numeric(), core.root_calculus.Value.is_numeric(), core.base_calculus.SquareRoot.is_numeric(), core.base_calculus.Operation.is_numeric(), core.calculus.Table.is_numeric(), core.base_calculus.Monomial.is_numeric(), core.base_calculus.Item.raw_value, core.root_calculus.Value.raw_value, core.base_calculus.Monomial.raw_value, core.base_calculus.Item.unit, and core.root_calculus.Value.unit.
def core.root_calculus.Value.set_sign | ( | self, | |
arg | |||
) |
Set the sign of the object.
arg | String being '+' or '-' or number being +1 or -1 |
Reimplemented from core.root_calculus.Signed.
Definition at line 633 of file root_calculus.py.
References core.base_calculus.Item._sign, core.root_calculus.Signed._sign, core.root_calculus.Value._sign, core.base_calculus.Function._sign, core.base_calculus.SquareRoot._sign, core.base_calculus.Quotient._sign, and core.base_calculus.Fraction._sign.
Referenced by core.base_calculus.Fraction.calculate_next_step(), core.base_calculus.Fraction.set_down_numerator_s_minus_sign(), core.root_calculus.Value.set_opposite_sign(), and core.base_calculus.Fraction.simplification_line().
def core.root_calculus.Value.set_unit | ( | self, | |
arg | |||
) |
Set the unit of the Value.
arg | String |
Definition at line 656 of file root_calculus.py.
References core.base_calculus.Item._unit, core.root_calculus.Value._unit, and core.base_calculus.Function._unit.
core::root_calculus.Value::has_been_rounded [static] |
property(get_has_been_rounded,
doc = "'has been rounded' state of the Value")
Definition at line 594 of file root_calculus.py.
Referenced by core.root_calculus.Value.__hash__(), and core.root_calculus.Value.contains_a_rounded_number().
core::root_calculus.Value::raw_value [static] |
property(get_raw_value,
doc = "Raw value of the object")
Definition at line 592 of file root_calculus.py.
Referenced by core.root_calculus.Value.__add__(), core.root_calculus.Value.__eq__(), core.root_calculus.Value.__hash__(), core.root_calculus.Value.__mul__(), core.root_calculus.Value.dbg_str(), core.root_calculus.Value.digits_number(), core.root_calculus.Value.evaluate(), core.root_calculus.Value.get_first_letter(), core.root_calculus.Value.get_iteration_list(), core.root_calculus.Value.into_str(), core.root_calculus.Value.is_a_perfect_square(), core.root_calculus.Value.is_displ_as_a_single_0(), core.root_calculus.Value.is_displ_as_a_single_1(), core.root_calculus.Value.is_displ_as_a_single_minus_1(), core.root_calculus.Value.is_literal(), core.root_calculus.Value.is_null(), core.root_calculus.Value.is_numeric(), and core.root_calculus.Value.round().
core::root_calculus.Value::sign [static] |
property(get_sign,
doc = "Sign of the Value")
Reimplemented from core.root_calculus.Signed.
Definition at line 596 of file root_calculus.py.
Referenced by core.root_calculus.Value.__hash__(), core.base_calculus.Operation.__hash__(), core.base_calculus.Product.__hash__(), and core.root_calculus.Value.set_opposite_sign().
core::root_calculus.Value::unit [static] |
property(get_unit,
doc = "Unit of the Value")
Definition at line 599 of file root_calculus.py.
Referenced by core.root_calculus.Value.__hash__(), and core.root_calculus.Value.into_str().