obj::calc::Item Class Reference

It's the smallest displayable element (sign, value, exponent) The value can be either numeric or literal. More...

Inheritance diagram for obj::calc::Item:
obj::calc::Exponented obj::calc::Calculable obj::Printable

List of all members.

Public Member Functions

def __init__
 Constructor.
def __str__
 Raw display of the Item (debugging method).
def __cmp__
 Compares two Items.
def __len__
 Returns the Item's length.
def is_numeric
 True if it's a numeric Item.
def is_literal
 True if it's a literal Item.
def is_null
 True if it's the null Item.
def is_negative
 True if Item's *sign* is '-' (ie -(-1) would be "negative").
def is_positive
 True if Item's *sign* is '+'.
def turn_into_fraction
 Turns the Item into the fraction item itself over item 1.
def is_equivalent_to_a_single_1
 True if it's positive w/ (exponent 0 or numeric w/ value 1).
def is_equivalent_to_a_single_minus_1
 True if it's negative w/ (exponent 0 or numeric w/ value 1).
def is_equivalent_to_a_single_0
 True if self.is_null().
def is_equivalent_to_a_single_numeric_Item
 True if the Item is numeric.
def is_equivalent_to_an_irreducible_Fraction
 True if the object is or only contains one irreducible Fraction.
def is_expandable
 False.
def multiply_symbol_is_required
 True if the usual writing rules require a × between two factors.
def requires_brackets
 True if the argument requires brackets in a product For instance, a Sum with several terms or a negative Item.
def requires_inner_brackets
 True if the object requires inner brackets The reason for requiring them is having a negative *value* and if the exponent is either :

  • (numeric Item | number) and even
  • (numeric Item | number) equivalent to 1 the object has a '-' *sign*
  • litteral Item
  • any Exponented apart from Items.

def contains_exactly
 Always False for an Item.
def contains_a_rounded_number
 To check if this contains a rounded number.
def get_value
 Gets the value (value_object.value) of the Item.
def get_sign
 Gets the sign of the Item.
def get_minus_signs_nb
 Gets the number of '-' signs of the Item.
def get_letter
 Returns the letter of the Item, in case it's a literal.
def set_is_out_striked
 Sets a value to the "is_out_striked" field If is_out_striked is set to True, the Item will be displayed out striked.
def set_unit
 Sets a value to the "unit" field.
def evaluate
 Returns the value of a numerically evaluable Item.
def calculate_next_step
 Returns None|an Item.
def round
 Returns the (numeric) Item once rounded to the given precision.
def digits_number
 Returns the number of digits of a numerical Item.
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) If the Item is not numeric, or if the given precision is incorrect, the matching call to the Value will raise an exception.
def expand_and_reduce_next_step
 Returns None (an Item can't get expanded nor reduced !).
def make_string
 Creates a string of the given object in the given ML.

Detailed Description

It's the smallest displayable element (sign, value, exponent) The value can be either numeric or literal.

Definition at line 1005 of file __init__.py.


Member Function Documentation

def obj::calc::Item::__cmp__ (   self,
  other_item 
)

Compares two Items.

Returns:
0 (i.e. they're equal) if sign, value & exponent are equal ?

Definition at line 1154 of file __init__.py.

def obj::calc::Item::__init__ (   self,
  arg 
)

Constructor.

Warning:
Might raise an UncompatibleType exception.
Parameters:
arg None|Number|String|Item|(sign,value,exponent)| (sign,number|letter|Value)|0-degree Monomial|Value Possible arguments can be :

  • a number which will will be the same as (sign_number, number, 1)
  • a letter : for example, passing 'a' is equivalent to ('+', 'a', 1) but passing '-x' is equivalent to ('-', 'x', 1) further characters are ignored ('ax' is equivalent to 'a')
  • another Item which will be copied
  • a tuple ('+'|'-', number|string)
  • a tuple ('+'|'-', number|string, <exponent as number|Exponented>)
  • None which will be the same as giving 1
  • a Monomial of degree zero and coefficient is an Item The is_out_striked field will always be initialized at False but will be copied in the case of an Item given as argument. If the argument is not of one of these kinds, an exception will be raised.
Returns:
One instance of Item

Definition at line 1032 of file __init__.py.

def obj::calc::Item::__len__ (   self  ) 

Returns the Item's length.

Returns:
1

Definition at line 1173 of file __init__.py.

def obj::calc::Item::__str__ (   self,
  options 
)

Raw display of the Item (debugging method).

Parameters:
options No option available so far
Returns:
A string containing "{sign value ^ exponent}"

Definition at line 1134 of file __init__.py.

def obj::calc::Item::calculate_next_step (   self,
  options 
)

Returns None|an Item.

Todo:
Manage the case when the exponent is a calculable that should be calculated itself.
Warning:
Relays an exception if the exponent is not Exponented|Value If the Item has an exponent equivalent to a single 1, then nothing can be calculated, so this method returns None In another case, it returns the evaluated Item

Reimplemented from obj::calc::Exponented.

Definition at line 1646 of file __init__.py.

def obj::calc::Item::contains_a_rounded_number (   self  ) 

To check if this contains a rounded number.

..

Returns:
True or False depending on the Value inside

Reimplemented from obj::calc::Exponented.

Definition at line 1523 of file __init__.py.

def obj::calc::Item::contains_exactly (   self,
  objct 
)

Always False for an Item.

Parameters:
objct The object to search for
Returns:
False

Reimplemented from obj::calc::Exponented.

Definition at line 1511 of file __init__.py.

def obj::calc::Item::evaluate (   self  ) 

Returns the value of a numerically evaluable Item.

Warning:
Relays an exception if the exponent is not Exponented|Value

Reimplemented from obj::calc::Calculable.

Definition at line 1621 of file __init__.py.

def obj::calc::Item::expand_and_reduce_next_step (   self,
  options 
)

Returns None (an Item can't get expanded nor reduced !).

Returns:
Exponented

Reimplemented from obj::calc::Exponented.

Definition at line 1748 of file __init__.py.

def obj::calc::Item::get_minus_signs_nb (   self  ) 

Gets the number of '-' signs of the Item.

Returns:
The number of '-' signs of the Item (either 0, 1 or 2)

Reimplemented from obj::calc::Exponented.

Definition at line 1562 of file __init__.py.

def obj::calc::Item::get_sign (   self  ) 

Gets the sign of the Item.

Returns:
The sign of the Item

Reimplemented from obj::calc::Exponented.

Definition at line 1548 of file __init__.py.

def obj::calc::Item::get_value (   self  ) 

Gets the value (value_object.value) of the Item.

Returns:
value_object.value

Definition at line 1535 of file __init__.py.

def obj::calc::Item::is_expandable (   self  ) 

False.

Returns:
False

Definition at line 1334 of file __init__.py.

def obj::calc::Item::is_negative (   self  ) 

True if Item's *sign* is '-' (ie -(-1) would be "negative").

Todo:
How to answer to the question if this Item is null ?

Definition at line 1225 of file __init__.py.

def obj::calc::Item::is_positive (   self  ) 

True if Item's *sign* is '+'.

Todo:
How to answer to the question if this Item is null ?

Definition at line 1240 of file __init__.py.

def obj::calc::Item::make_string (   self,
  markup,
  options 
)

Creates a string of the given object in the given ML.

Parameters:
markup The markup dictionary to use
options Any options
Returns:
The formated string

Reimplemented from obj::Printable.

Definition at line 1764 of file __init__.py.

def obj::calc::Item::multiply_symbol_is_required (   self,
  objct,
  position 
)

True if the usual writing rules require a × between two factors.

Parameters:
objct The other one
position The position (integer) of self in the Product
Returns:
True if the writing rules require × between self & obj

Reimplemented from obj::calc::Exponented.

Definition at line 1347 of file __init__.py.

def obj::calc::Item::needs_to_get_rounded (   self,
  precision 
)

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) If the Item is not numeric, or if the given precision is incorrect, the matching call to the Value will raise an exception.

Definition at line 1735 of file __init__.py.

def obj::calc::Item::requires_brackets (   self,
  position 
)

True if the argument requires brackets in a product For instance, a Sum with several terms or a negative Item.

Parameters:
position The position of the object in the Product
Returns:
True if the object requires brackets in a Product

Reimplemented from obj::calc::Exponented.

Definition at line 1419 of file __init__.py.

def obj::calc::Item::requires_inner_brackets (   self  ) 

True if the object requires inner brackets The reason for requiring them is having a negative *value* and if the exponent is either :

  • (numeric Item | number) and even
  • (numeric Item | number) equivalent to 1 the object has a '-' *sign*
  • litteral Item
  • any Exponented apart from Items.

Todo:

Case of non-Item-Exponented exponents probably is to be improved

Case of numerator-only equivalent Quotients not made so far

Returns:
True if the object requires inner brackets

Reimplemented from obj::calc::Exponented.

Definition at line 1452 of file __init__.py.


The documentation for this class was generated from the following file:
Generated on Fri Dec 30 19:26:37 2011 for mathmaker by  doxygen 1.6.3