mathmaker.lib.core package¶
Submodules¶
mathmaker.lib.core.base module¶
-
class
mathmaker.lib.core.base.
Drawable
[source]¶ Bases:
mathmaker.lib.core.base.NamedObject
-
eps_filename
¶
-
euk_filename
¶
-
name
¶
-
-
class
mathmaker.lib.core.base.
NamedObject
[source]¶ Bases:
mathmaker.lib.core.base.Clonable
-
name
¶
-
-
class
mathmaker.lib.core.base.
Printable
[source]¶ Bases:
mathmaker.lib.core.base.NamedObject
-
jsprinted
¶ Shortcut for self.into_str(force_expression_begins=True, js_repr=True)
This returns the string of the Printable object, assuming it starts the expression.
-
printed
¶ Shortcut for self.into_str(force_expression_begins=True)
This returns the string of the Printable object, assuming it starts the expression.
-
mathmaker.lib.core.base_calculus module¶
-
class
mathmaker.lib.core.base_calculus.
AngleItem
(raw_value=None, copy_this=None, from_this_angle=None)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Item
Represent Angles’ names, like widehat{ABC} (handled as Items).
-
class
mathmaker.lib.core.base_calculus.
BinomialIdentity
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Expandable
-
a
¶ Gets the ‘a’ term of the BinomialIdentity
-
b
¶ Gets the ‘b’ term of the BinomialIdentity
-
kind
¶ kind of BinomialIdentity it, e.g. ‘sum_square’|’difference_square’|’squares_difference’
-
-
class
mathmaker.lib.core.base_calculus.
CommutativeOperation
[source]¶ Bases:
mathmaker.lib.core.base_calculus.Operation
-
compact_display
¶ compact_display field of a CommutativeOperation
-
info
¶ info field of a CommutativeOperation
-
-
class
mathmaker.lib.core.base_calculus.
Division
(arg, ignore_1_denominator=False, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Quotient
Same as Quotient, but using ÷ sign as default.
-
class
mathmaker.lib.core.base_calculus.
Fraction
(arg, ignore_1_denominator=False, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Quotient
-
expand_and_reduce_next_step
(**options)[source]¶ If possible, expands Quotient’s numerator and/or denominator.
-
same_deno_reduction_in_progress
¶ Fraction’s same_deno_reduction_in_progress field
-
simplification_in_progress
¶ Fraction’s simplification_in_progress status
-
status
¶ Fraction’s status
-
-
class
mathmaker.lib.core.base_calculus.
Function
(copy_this=None, name='f', var= {+x (unit='') ^.1.}, fct=<function Function.<lambda>>, num_val=.1., display_mode='literal', inv_fct=None, unlocked=False)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Item
Represent the image of a number under a function like f(x) or cos(ABC).
-
argument
¶
-
calculate_next_step
(**options)[source]¶ Will only swap to numeric argument, no automatic evaluation.
-
fct
¶ The lambda function to use for evaluation.
-
get_minus_signs_nb
()[source]¶ 1 if Function object has a negative sign and no even exponent, else 0.
-
image_notation
¶
-
inv_fct
¶ The lambda function to use for evaluation.
-
is_displ_as_a_single_numeric_Item
()[source]¶ f(x) is never a single numeric Item (like any single number).
-
is_literal
(displ_as=False) → bool[source]¶ Return True if Function is to be considered literal.
Parameters: displ_as – if displ_as is True, it’s about knowing whether the object should be considered literal for display, otherwise, it’s about knowing wether it can be numerically evaluated (directly, without replacing its variable by a Value).
-
is_numeric
(displ_as=False)[source]¶ Return True if current display mode is numeric.
Parameters: displ_as – if displ_as is True, it’s about knowing whether the object should be considered numeric for display, otherwise, it’s about knowing wether it can be numerically evaluated (directly, without replacing its variable by a Value).
-
multiply_symbol_is_required
(objct, position)[source]¶ True if × is required between self and next objct in a Product.
-
num_val
¶
-
unlocked
¶
-
var
¶
-
-
class
mathmaker.lib.core.base_calculus.
Item
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.root_calculus.Exponented
-
force_display_sign_once
¶ Item’s force_display_sign_once field
-
is_literal
(displ_as=False) → bool[source]¶ Return True if Item is to be considered literal.
Parameters: displ_as – not applicable to Items
-
is_out_striked
¶ Item’s is_out_striked field
-
raw_value
¶ Item’s raw value
-
unit
¶ Unit of the Item
-
value_inside
¶ Item’s Value
-
-
class
mathmaker.lib.core.base_calculus.
Monomial
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Product
-
coeff
¶ Monomial’s coefficient
-
degree
¶ Monomial’s degree
-
letter
¶ Monomial’s letter
-
raw_value
¶ 0-degree-Monomial’s value
-
sign
¶ Monomial’s sign
-
value_inside
¶ 0-degree Monomial’s Value inside
-
-
class
mathmaker.lib.core.base_calculus.
Operation
[source]¶ Bases:
mathmaker.lib.core.root_calculus.Exponented
-
element
¶ element field of Operation
-
is_literal
(displ_as=False) → bool[source]¶ Return True if Operation is to be considered literal.
Parameters: displ_as – not applicable to Operations
-
neutral
¶ neutral field of Operation
-
symbol
¶ symbol field of Operation
-
-
class
mathmaker.lib.core.base_calculus.
Polynomial
(arg)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Sum
-
degree
¶ Real degree of the Polynomial
-
-
class
mathmaker.lib.core.base_calculus.
Product
(arg, compact_display=True)[source]¶ Bases:
mathmaker.lib.core.base_calculus.CommutativeOperation
-
factor
¶ To access the factors of the Product.
-
-
class
mathmaker.lib.core.base_calculus.
Quotient
(arg, ignore_1_denominator=False, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Operation
-
denominator
¶ denominator field of Quotient
-
expand_and_reduce_next_step
(**options)[source]¶ If possible, expands Quotient’s numerator and/or denominator.
-
numerator
¶ numerator field of Quotient
-
-
class
mathmaker.lib.core.base_calculus.
SquareRoot
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base_calculus.Function
-
calculate_next_step
(**options)[source]¶ Will only swap to numeric argument, no automatic evaluation.
-
force_display_sign_once
¶ Item’s force_display_sign_once field
-
get_minus_signs_nb
()[source]¶ 1 if Function object has a negative sign and no even exponent, else 0.
-
is_displ_as_a_single_numeric_Item
()[source]¶ f(x) is never a single numeric Item (like any single number).
-
is_literal
(displ_as=False)[source]¶ Return True if SquareRoot is to be considered literal.
Parameters: displ_as – not applicable to SquareRoots
-
is_numeric
(displ_as=False)[source]¶ Return True if current display mode is numeric.
Parameters: displ_as – if displ_as is True, it’s about knowing whether the object should be considered numeric for display, otherwise, it’s about knowing wether it can be numerically evaluated (directly, without replacing its variable by a Value).
-
-
class
mathmaker.lib.core.base_calculus.
Sum
(arg)[source]¶ Bases:
mathmaker.lib.core.base_calculus.CommutativeOperation
-
force_inner_brackets_display
¶ force_inner_brackets_display field of a Sum
-
term
¶ To access the terms of the Sum.
-
mathmaker.lib.core.base_geometry module¶
-
class
mathmaker.lib.core.base_geometry.
Angle
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base.Drawable
,mathmaker.lib.core.base.Printable
-
label
¶
-
label_display_angle
¶
-
mark
¶
-
measure
¶
-
points
¶
-
vertex
¶
-
-
class
mathmaker.lib.core.base_geometry.
Point
(name=None, x=None, y=None)[source]¶ Bases:
mathmaker.lib.core.base.Drawable
-
name
¶
-
x
¶
-
x_exact
¶
-
xy
¶
-
y
¶
-
y_exact
¶
-
-
class
mathmaker.lib.core.base_geometry.
Segment
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base.Drawable
-
dividing_points
(n=1, prefix='a')[source]¶ Create the list of Points that divide the Segment in n parts.
Parameters: n (int) – the number of parts (so it will create n - 1 points) n must be greater or equal to 1
-
label
¶ Label of the Segment (the displayed information).
-
length
¶ Fake length of the Segment (the one used in a problem).
-
length_has_been_set
¶ Whether the (fake) length has been set or not.
-
length_name
¶ Length’s name of the Segment, like AB.
-
mark
¶
-
points
¶
-
real_length
¶ Real length (build length) of the Segment.
-
-
class
mathmaker.lib.core.base_geometry.
Vector
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.base_geometry.Point
-
bisector_vector
(arg)[source]¶ Return a vector colinear to the bisector of self and another vector.
Parameters: arg (Vector) – the other vector
-
norm
¶ Return the norm of self.
-
orthogonal_unit_vector
(clockwise=True)[source]¶ Return a unit vector that’s (default clockwise) orthogonal to self.
If clockwise is set to False, then the anti-clockwise orthogonal vector is returned.
-
slope
¶ Return the slope of self.
-
mathmaker.lib.core.calculus module¶
-
class
mathmaker.lib.core.calculus.
CrossProductEquation
(arg)[source]¶ Bases:
mathmaker.lib.core.calculus.Equation
-
variable_obj
¶ Variable object of the Equation
-
variable_position
¶ Variable position in the Equation
-
-
class
mathmaker.lib.core.calculus.
Equality
(objcts, subst_dict=None, **options)[source]¶ Bases:
mathmaker.lib.core.calculus.ComposedCalculable
,mathmaker.lib.core.root_calculus.Substitutable
-
content
¶ The content to be substituted (list containing literal objects).
-
elements
¶ Elements of the object
-
equal_signs
¶ Equal signs of the object
-
-
class
mathmaker.lib.core.calculus.
Equation
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.calculus.ComposedCalculable
-
left_hand_side
¶ Left hand side of the Equation
-
name
¶
-
number
¶ Number of the Equation
-
right_hand_side
¶ Right hand side of the Equation
-
variable_letter
¶ Variable letter of the Equation
-
-
class
mathmaker.lib.core.calculus.
Expression
(integer_or_letter, objct)[source]¶ Bases:
mathmaker.lib.core.calculus.ComposedCalculable
-
right_hand_side
¶ Right hand side of the object
-
-
class
mathmaker.lib.core.calculus.
QuotientsEquality
(arg, displ_as_qe=True, ignore_1_denos=True, subst_dict=None)[source]¶ Bases:
mathmaker.lib.core.calculus.Table
A shortcut to create Tables as quotients equalities.
-
class
mathmaker.lib.core.calculus.
Table
(arg, displ_as_qe=False, ignore_1_denos=None, subst_dict=None)[source]¶ Bases:
mathmaker.lib.core.base.Printable
,mathmaker.lib.core.root_calculus.Substitutable
-
class
SubstitutableList
(*args, subst_dict=None)[source]¶ Bases:
list
,mathmaker.lib.core.root_calculus.Substitutable
A list that can call substitute() on its elements.
-
content
¶ The content to be substituted (list containing literal objects).
-
-
cell
¶ t.cell is the complete Table t.cell[i][j] is a cell
-
content
¶ The content to be substituted (list containing literal objects).
-
displ_as_qe
¶
-
ignore_1_denos
¶
-
into_crossproduct_equation
(col0=0, col1=1) → mathmaker.lib.core.calculus.CrossProductEquation[source]¶ Create a CrossProductEquation from two columns.
Ensure there is only one literal among the four cells before using it.
Parameters: - col0 – the number of the first column to use
- col1 – the number of the second column to use
-
class
-
class
mathmaker.lib.core.calculus.
Table_UP
(coeff, first_line, info, displ_as_qe=False)[source]¶ Bases:
mathmaker.lib.core.calculus.Table
-
coeff
¶ the coefficient of the Table_UP
-
crossproducts_info
¶ infos about the cross products
-
mathmaker.lib.core.geometry module¶
-
class
mathmaker.lib.core.geometry.
InterceptTheoremConfiguration
(points_names=None, butterfly=False, sketch=True, build_ratio=None, build_dimensions=None, rotate_around_isobarycenter='no')[source]¶ Bases:
mathmaker.lib.core.geometry.Triangle
-
butterfly
¶
-
chunk
¶
-
enlargement_ratio
¶
-
point
¶
-
ratios_equalities
() → mathmaker.lib.core.calculus.Table[source]¶ Return a Table matching the ratios equalities.
-
ratios_equalities_substituted
() → mathmaker.lib.core.calculus.Table_UP[source]¶ Return the ratios equalities containing known numbers.
It is returned as a Table_UP object.
-
ratios_for_converse
() → mathmaker.lib.core.calculus.Table[source]¶ Return a Table matching the ratios equality for converse.
-
set_lengths
(lengths_list, enlargement_ratio)[source]¶ Set all (“fake”) lengths of the figure.
The given lengths’ list matches the three small sides. The ratio will be used to compute all other segments’ sides. As these lengths are the “fake” ones (not the ones used to draw the figure, but the ones that will show up on the figure), this ratio is the “fake” one (not the same as self.ratio).
Parameters: - lengths_list (a list (of Values)) – the list of the lengths for small0, small1, small2
- enlargement_ratio (any Evaluable) – the enlargement ratio of the exercise.
-
small
¶
-
u
¶
-
v
¶
-
-
class
mathmaker.lib.core.geometry.
Polygon
(arg, shapecolor='', **options)[source]¶ Bases:
mathmaker.lib.core.base.Drawable
-
angle
¶
-
filename
¶
-
lengths_have_been_set
¶
-
name
¶
-
nature
¶
-
perimeter
¶
-
rotation_angle
¶
-
setup_labels
(flags_list, segments_list=None)[source]¶ Tells what to display along each segment of the list.
If no segments’ list is provided, it defaults to the Polygon’s sides’ list. It is expected that both the flags’ and segments’ lists have the same length. Meaning of the flags’ list: - a ‘?’ will be displayed for each Segment flagged as None or ‘?’ - its length will be displayed if it’s flagged as anything else
evaluating to True- nothing will be displayed it it’s flagged as anything else evaluating to False
Parameters: - flags_list (list) – the list of the flags
- segments_list (list (of Segments)) – the list of the Segments to flag
-
side
¶
-
vertex
¶
-
-
class
mathmaker.lib.core.geometry.
Rectangle
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.geometry.Polygon
-
area
¶
-
length
¶
-
width
¶
-
-
class
mathmaker.lib.core.geometry.
RectangleGrid
(arg, layout='2×2', fill='0×0', autofit=False, fillcolor='lightgray', startvertex=None)[source]¶
-
class
mathmaker.lib.core.geometry.
RightTriangle
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.geometry.Triangle
-
hypotenuse
¶
-
leg
¶
-
right_angle
¶
-
setup_for_trigonometry
(angle_nb=None, trigo_fct=None, angle_val=None, up_length_val=None, down_length_val=None, length_unit=None, only_mark_unknown_angle=False, mark_angle='simple')[source]¶ Setup labels, determine subst_dict and stores configuration details.
Exactly one parameter among the three *_val ones must be left to None. According to the chosen trigo_fct and this parameter, this method will create the correct subst_dict.
Parameters: - angle_nb (int) – must be either 0 or 2 (index of an acute angle)
- trigo_fct (str) – must belong to [‘cos’, ‘sin’, ‘tan’]
- angle_val (Value (or leave it to None to use it as the unknown value to calculate)) – the angle’s Value
- up_length_val (Value (or leave it to None to use it as the unknown value to calculate)) – the length’s Value of the side that’s at the numerator of the trigonometric formula
- down_length_val (Value (or leave it to None to use it as the unknown value to calculate)) – the length’s Value of the side that’s at the denominator of the trigonometric formula
- length_unit (anything that can be used as argument for Units) – the length’s unit to use for lengths
-
side_adjacent_to
(angle=None)[source]¶ Return the side adjacent to given angle.
Parameters: angle (must be self.angle[0] or self.angle[2]) – one of the acute angles
-
side_opposite_to
(angle=None)[source]¶ Return the side opposite to given angle.
Parameters: angle (must be self.angle[0] or self.angle[2]) – one of the acute angles
-
trigonometric_equality
(angle=None, trigo_fct=None, subst_dict=None, autosetup=False)[source]¶ Return the required trigonometric equality.
Parameters: - angle (Angle) – the acute Angle to use
- trigo_fct (str) – either ‘cos’, ‘sin’ or ‘tan’
- subst_dict (dict) – a correct substitution dictionary
- autosetup (bool) – if enabled, will take the angle, trigo_fct and subst_dict from preconfigured values (requires to have called setup_for_trigonometry() previously).
-
-
class
mathmaker.lib.core.geometry.
Square
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.geometry.Polygon
-
area
¶
-
side_length
¶
-
mathmaker.lib.core.root_calculus module¶
-
class
mathmaker.lib.core.root_calculus.
Exponented
[source]¶ Bases:
mathmaker.lib.core.root_calculus.Signed
-
exponent
¶ Exponent of the Function
-
-
class
mathmaker.lib.core.root_calculus.
Signed
[source]¶ Bases:
mathmaker.lib.core.root_calculus.Calculable
-
sign
¶ Sign of the object
-
-
class
mathmaker.lib.core.root_calculus.
Substitutable
(subst_dict=None)[source]¶ Bases:
object
Any object whose (literal) value(s) can be substituted by numeric ones.
Any Substitutable must define a content property, should include an optional subst_dict argument in its __init__() method and must ensure that a _subst_dict is defined (an easy way to do this is calling Substitutable.__init__(self, subst_dict=subst_dict). The substitute() method is redefined by some Substitutable objects.
-
content
¶ The content to be substituted (list containing literal objects).
-
subst_dict
¶ Get the default dictionary to use for substitution.
-
-
class
mathmaker.lib.core.root_calculus.
Unit
(arg, **options)[source]¶ Bases:
mathmaker.lib.core.root_calculus.Exponented
-
exponent
¶ Exponent of the Function
-
name
¶
-
-
class
mathmaker.lib.core.root_calculus.
Value
(arg, text_in_maths=True, **options)[source]¶ Bases:
mathmaker.lib.core.root_calculus.Signed
-
abs_value
¶
-
has_been_rounded
¶ ‘has been rounded’ state of the Value
-
is_literal
(displ_as=False) → bool[source]¶ Return True if Value is to be considered literal.
Parameters: displ_as – not applicable to Values
-
raw_value
¶
-
sign
¶ Sign of the Value
-
unit
¶ Unit of the Value
-
mathmaker.lib.core.utils module¶
-
mathmaker.lib.core.utils.
gather_literals
(xpr)[source]¶ Return all literal Values|AngleItems of an expression.
Parameters: xpr (Calculable) – the expression to iter over