Menu

Evaluable

Nicolas Hainaux

Evaluable objects are the ones from which a numeric value may be calculated. The main method is evaluate().

This is basically the case of all simple calculus objects (like Values, Items, Products etc.) but not the case of composed calculus objects (like Equations : you can not calculate an Equation, even if you can calculate each of its members separately).

This class was thought to gather methods that are related to numeric evaluation but also comparison. It has not been merged with Calculable and Signed, which where thought to gather other sorts of methods.

Of course, if evaluate() is called on a literal object, it will raise an exception ; but still there's no need to put literal objects apart from the numeric ones : first because they follow the same writing rules ; and second because they may be substituted by numeric objects. So, just take care to not call evaluate() on literal objects.

Fields Methods (provided) Methods (must be reimplemented)
comparison_method() evaluate()
contains_a_rounded_number()
contains_exactly()
get_first_letter()
is_numeric()
is_literal()
is_null()

comparison_method() will certainly change during the process of migration to python3, so I won't describe it here longer, for now (it's alphabetical_order_cmp())

evaluate() is the only method that will raise an Exception if called on a literal object

contains_a_rounded_number() and contains_exactly() will just return boolean True/False
contains_exactly() is used to determine if an object is just a container for another, for example, to check if a Sum or a Product does have only one element being the Item we're looking for.

get_first_letter() is used to compare literals and in Value.__init__() and in Equation.__init__()

Check Evaluable's complete doc

Back


Related

Doc for dev: Core Objects

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.