Commit Graph

21 Commits

Author SHA1 Message Date
Hugo Saint-Vignes
e09bd0a18c [poincare] Factorize reduce and removeUnit methods 2020-12-22 17:32:40 +01:00
Hugo Saint-Vignes
7146eff7ee [poincare/src] Use reduce before removeUnit
With deepReduce(), when a simplifiaction was interrupted, expression could
contain Undefined children, which would trigger the assert in
removeUnit(). With reduce(), if a simplification is interrupted, the
entire expression becomes Undefined, which is handled by removeUnits().
2020-12-22 17:32:40 +01:00
Léa Saviot
5df60e946a [poincare] shallowBeautify can modify the reduction context
UnitConvert must set UnitConversion to None, otherwise the unit asked
for in the conversion might get changed after being properly set in
UnitConvert::shallowBeautify.
2020-11-09 15:50:27 +01:00
Émilie Feral
7142f9545e [poincare] Finish replacing approximateContext 2020-11-04 15:58:41 +01:00
Gabriel Ozouf
d37540f032 [poincare/unit] Add Celsius and Fahrenheit
Temperatures can be converted to and from degree Celsius and Fahrenheit.
When used in non-trivial calculations, they are always reduced to undef,
as the rules for manipulating relative scales are not well defined.

Change-Id: If59e224a0e7f940b421bc894bbe2279c90f38d04
2020-11-04 15:33:00 +01:00
Gabriel Ozouf
d917b2e1c9 [poincare/unit_convert] Fix improper reduction
In UnitConvert::shallowBeautify, an orphan expression would be reduced
without reaffecting the reduction's result. The reduction not being
taken into account would cause problem when handling undef values.
ex : Try to calculate i->_min

Change-Id: I4e53afa40ba838fed8c2fba9944c9c9ed1dc95b4
2020-11-04 15:30:53 +01:00
Gabriel Ozouf
fad375c11c [poincare] Add unitFormat to ReductionContext
Change-Id: I1d3fcd2f47c973c041e1be84e9a902dd58de3562
2020-11-04 15:11:44 +01:00
Léa Saviot
c20261940f [poincare] Handle removeUnit that create Undefined expressions
UnitConvert::removeUnit replaces the unit ocnvert with an undefined.
2020-07-16 11:46:23 +02:00
Émilie Feral
ade90db392 [poincare] UnitConvert: implement removeUnit since UnitConvert can be a
reduced expression
2020-06-04 14:50:09 +02:00
Émilie Feral
3308b13b9c [poincare] UnitConvert:
- do the smart part at beautification to avoid
requiring an escape case just for UnitConvert
- Use UnitConvert::None
2020-06-04 14:50:01 +02:00
Émilie Feral
3f34e5e644 [poincare] Enable to choose the "UnitConversion" mode at simplification
between: only SI, none, default...
2020-06-04 14:50:01 +02:00
Émilie Feral
d805c59202 [poincare] Fix extractUnit into removeUnit paradigm 2020-06-04 14:50:01 +02:00
Ruben Dashyan
407ce0534c [poincare/expression] Use extractUnits instead of hasUnit when possible 2020-06-04 14:50:01 +02:00
Ruben Dashyan
bf9653d510 [poincare/expression] Turn getUnit into extractUnits
Addition::shallowReduce factors the unit across its terms.
Previously expressions of the form 1_m+π_m were reduced to undef.
2020-06-04 14:50:01 +02:00
Ruben Dashyan
965e3b1d9a [poincare/n_ary_expression] Factor mergeMultiplicationChildrenInPlace
from Multiplication to NAryExpression so as to use it in Addition
2020-06-04 14:50:01 +02:00
Ruben Dashyan
0c4434d088 [poincare/expression] getUnit returns an uninitialized Expression
when there is no Unit instead of Undefined
2020-06-04 14:50:01 +02:00
Léa Saviot
94d71634b6 [poincare/unit_convert] In shallowReduce, fix units testing on the right
First reduce the right member by replacing the units to make sure there
is a unit, then reduce without replacing to keep "complex units" such as
L, N, ...
2020-02-12 15:13:25 +01:00
Léa Saviot
d5b07f1f90 [poincare] Implemment getUnit 2020-02-12 15:13:25 +01:00
Léa Saviot
ecdcb100fb [poincare/unit_convert] Fix UnitConvert::shallowReduce 2020-02-12 15:13:25 +01:00
Léa Saviot
7a65e5180b [poincare/right_arrow_expression] Factorize Store and UnivtConvert 2020-02-12 15:13:24 +01:00
Léa Saviot
c543985094 [poincare] Unit conversion 2020-02-12 15:13:24 +01:00