Skip to content

Commit

Permalink
Fix #39: Hour as h unit and °C as degreeCelsius
Browse files Browse the repository at this point in the history
  • Loading branch information
jon85p committed Jan 26, 2021
1 parent 60a151c commit 6f6a99e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions entrada.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from numpy import inf
from CoolProp.CoolProp import PropsSI as prop
from CoolProp.CoolProp import HAPropsSI as haprop
from re import sub
from time import time
import optparse
from pint import _DEFAULT_REGISTRY as pyENLu
Expand Down Expand Up @@ -97,6 +98,11 @@ def entradaTexto(ecuaciones, pyENL_timeout, varsObj=None, tol=None, method='hybr
expresion = expresion.replace('\t','')
# Capacidad de interpretar pow
expresion = expresion.replace("^", "**")
if "hour" not in expresion:
expresion = sub(r'\[([A-z0-9\*{1,2}\/\^)]*)h([A-z0-9\*{1,2}\/\^)]*)]',
'[\g<1>hour\g<2>]', expresion)
expresion = sub(r'\[([A-z0-9\*{1,2}\/\^)]*)°C([A-z0-9\*{1,2}\/\^)]*)]',
'[\g<1>degree_Celsius\g<2>]', expresion)
izq_der = expresion.split('=')
operandos = ["+", "-", "*", "/", "("]
# Revisar que no haya operadores incompletos
Expand Down
6 changes: 6 additions & 0 deletions pyENL.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
pyENLu.load_definitions(pyENL_units_file)
from CoolProp.CoolProp import FluidsList, get_parameter_index, get_parameter_information, is_trivial_parameter
from pyENL_fcns.functions import dicc_coolprop
from re import sub
# Cargar ahora interfaz desde archivo .py haciendo conversión con:
# $ pyuic4 GUI/MainWindow.ui -o GUI/MainWindow.py
# Icono: QtWidgets.QPixmap(_fromUtf8("GUI/imgs/icon.ico")
Expand Down Expand Up @@ -857,6 +858,11 @@ def actualizaVarsTable(self):
lowerlim = float(self.varsTable.item(i, 2).text())
upperlim = float(self.varsTable.item(i, 3).text())
units = self.varsTable.item(i, 4).text()
if not "hour" in units:
units = sub(r'([A-z0-9\*{1,2}\/\^)]*)h([A-z0-9\*{1,2}\/\^)]*)',
'\g<1>hour\g<2>', units)
units = sub(r'([A-z0-9\*{1,2}\/\^)]*)°C([A-z0-9\*{1,2}\/\^)]*)',
'\g<1>degree_Celsius\g<2>', units)
comment = self.varsTable.item(i, 5).text()
if lowerlim >= upperlim:
raise Exception(self.traduccion['El número '] + str(lowerlim) +
Expand Down

0 comments on commit 6f6a99e

Please sign in to comment.