Skip to content

Commit

Permalink
v0.16.3: Fahrenheit to Celsius
Browse files Browse the repository at this point in the history
+ Updated AGeLib to v1.0.3
++ This makes alt+A the application wide shortcut for the advanced mode
++ The control window has the new advanced mode checkbox in the top bar
++ All instances where the advanced mode is relevant now ask the application instead of the options window
+ °F will now automatically be convert to °C
++ Sympy does not support temperatures so I added the conversion formula to the replacement tables
+++ Due to this an inverse conversion is not easily possible
+++ °C is recognized as a variable which means that one must be careful when solving for unknowns
+ Empty inputs are now recognized by AMaS and have a special error message
+ Units are now enabled by default
+ Inverse parsing of Greek letters now only converts them if they are not part of another word
+ Fixed some typos
  • Loading branch information
AstusRush committed Jan 27, 2020
1 parent 5d52128 commit 2723c32
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 142 deletions.
267 changes: 169 additions & 98 deletions AGeLib/AGeMain.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions AGeLib/Patchlog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ v1.0.2: Permanent Clipboard
+ On all other platforms any clipboard managers are given a last chance to store the clipboard before the application exits
+ (The clipboard resetting on application exit is a DX11 and OS feature and is hard to circumvent)

v1.0.3: Top Bar Improvements
+ NC now handles the displayed text, tool tip and flash which further simplifies the notification system and makes it more flexible
+ The advanced mode has been improved:
++ alt+A is the application wide shortcut
++ The top bar widget has an optional checkbox
+ The top bar widget error button now loads the last notifications on init
++ If there was no previous notification the user is greeted by username

43 changes: 27 additions & 16 deletions AMaDiA.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This Python file uses the following encoding: utf-8
Version = "0.16.2.4"
Version = "0.16.3"
Author = "Robin \'Astus\' Albers"
WindowTitle = "AMaDiA v"
WindowTitle+= Version
Expand Down Expand Up @@ -54,7 +54,7 @@
import re
import getpass

# import Math modules
# import Maths modules
import matplotlib
import sympy
from sympy.parsing.sympy_parser import parse_expr
Expand Down Expand Up @@ -120,22 +120,31 @@
#endregion

def AltGr_Shortcut(Symbol,shift_Symbol):
if keyboard.is_pressed("shift"):
AltGr_Shift_Shortcut(shift_Symbol)
if Keyboard_Remap_Works:
if keyboard.is_pressed("shift"):
AltGr_Shift_Shortcut(shift_Symbol)
else:
keyboard.write(Symbol)
keyboard.release("alt")
keyboard.release("control")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")
def AltGr_Shift_Shortcut(Symbol):
if Keyboard_Remap_Works:
keyboard.write(Symbol)
keyboard.release("alt")
keyboard.release("control")
def AltGr_Shift_Shortcut(Symbol):
keyboard.write(Symbol)
keyboard.release("alt")
keyboard.release("control")
keyboard.press("shift")
keyboard.press("shift")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")
def Superscript_Shortcut(Symbol):
#keyboard.write("\x08")
keyboard.write(Symbol)
keyboard.write(" ")
keyboard.write("\x08")
if Keyboard_Remap_Works:
#keyboard.write("\x08")
keyboard.write(Symbol)
keyboard.write(" ")
keyboard.write("\x08")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")

#region ---------------------------------- Windows ----------------------------------
class AMaDiA_Internal_File_Display_Window(AGeMain.AWWF):
Expand Down Expand Up @@ -212,7 +221,7 @@ class AMaDiA_exec_Window(AGeMain.AWWF):
def __init__(self,parent = None):
try:
super(AMaDiA_exec_Window, self).__init__(parent, initTopBar=False)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True, IncludeAdvancedCB=True)
self.setWindowTitle("Code Execution Window")
self.standardSize = (900, 500)
self.resize(*self.standardSize)
Expand Down Expand Up @@ -265,6 +274,8 @@ def __init__(self,app,parent = None):

def ConnectSignals(self):
self.fontComboBox.currentFontChanged.connect(self.SetFontFamily)
self.cb_O_AdvancedMode.clicked.connect(QtWidgets.QApplication.instance().ToggleAdvancedMode)
QtWidgets.QApplication.instance().S_advanced_mode_changed.connect(self.cb_O_AdvancedMode.setChecked)
self.cb_O_Remapper_global.toggled.connect(self.ToggleGlobalRemapper)
self.cb_O_PairHighlighter.toggled.connect(self.MainApp.S_Highlighter.emit)

Expand Down Expand Up @@ -665,8 +676,8 @@ def ConnectSignals(self):
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.toggled.connect(self.ToggleRemapper)
self.Menu_Options_action_Options.triggered.connect(self.MainApp.Show_Options)

self.MainApp.optionWindow.cb_O_AdvancedMode.toggled.connect(self.Menu_Options_action_Advanced_Mode.setChecked)
self.Menu_Options_action_Advanced_Mode.toggled.connect(self.MainApp.optionWindow.cb_O_AdvancedMode.setChecked)
self.Menu_Options_action_Advanced_Mode.toggled.connect(QtWidgets.QApplication.instance().ToggleAdvancedMode)
QtWidgets.QApplication.instance().S_advanced_mode_changed.connect(self.Menu_Options_action_Advanced_Mode.setChecked)

self.MainApp.optionWindow.cb_F_EvalF.toggled.connect(self.Menu_Options_action_Eval_Functions.setChecked)
self.Menu_Options_action_Eval_Functions.toggled.connect(self.MainApp.optionWindow.cb_F_EvalF.setChecked)
Expand Down
20 changes: 13 additions & 7 deletions AMaDiA_Files/AMaDiA_Classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ def __init__(self, string, Iam, EvalL = 1):
self.VariablesUnev = {}
with QtCore.QMutexLocker(self.NotificationMutex):
self.NotificationList = []
try:
self.INIT_WhatAmI(string)
except common_exceptions :
self.Notify(NC(1,"Could not calculate values for plot",func="AMaS.Plot_2D_Calc_Values",exc=sys.exc_info()))

if string == "":
N = NC(1,"ERROR: No input",func="AMaS.__init__",DplStr="Please give an input")
self.Notify(N)
self.Exists = False
else:
self.Exists = True
try:
self.INIT_WhatAmI(string)
except common_exceptions :
self.Notify(NC(1,"Could not create AMaS object",func="AMaS.__init__",exc=sys.exc_info(),input=string))
self.Exists = False
else:
self.Exists = True

def init_bools(self):
self.multiline = False
Expand Down Expand Up @@ -390,7 +396,7 @@ def ConvertToLaTeX(self):
def ConvertToLaTeX_Equation(self):
"""Convert the entire Equation to LaTeX"""
try:
temp = AF.AstusParse(self.Equation)
temp = AF.AstusParse(self.Equation,False)
if "==>" in temp:
parts = temp.split("==>")
self.LaTeX_E = ""
Expand Down Expand Up @@ -455,7 +461,7 @@ def ConvertToLaTeX_Equation(self):
self.LaTeX_E_N += "$"
#Reverse Equation:
try:
temp = AF.AstusParse(self.EquationReverse)
temp = AF.AstusParse(self.EquationReverse,False)
if "<==" in temp:
parts = temp.split("<==")
self.LaTeX_ER = ""
Expand Down
19 changes: 10 additions & 9 deletions AMaDiA_Files/AMaDiA_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ def cTimeSStr():
"""
return str(datetime.datetime.now().strftime('%H:%M:%S'))

def cTimeFullStr(seperator = None):
def cTimeFullStr(separator = None):
"""
Returns the date and time as a string\n
If given uses `separator` to separate the values\n
%Y.%m.%d-%H:%M:%S or seperator.join(['%Y','%m','%d','%H','%M','%S'])
%Y.%m.%d-%H:%M:%S or separator.join(['%Y','%m','%d','%H','%M','%S'])
"""
if seperator == None:
if separator == None:
return str(datetime.datetime.now().strftime('%Y.%m.%d-%H:%M:%S'))
else:
TheFormat = seperator.join(['%Y','%m','%d','%H','%M','%S'])
TheFormat = separator.join(['%Y','%m','%d','%H','%M','%S'])
return str(datetime.datetime.now().strftime(TheFormat))

def takeFirst(elem):
Expand Down Expand Up @@ -368,7 +368,7 @@ def AstusParse(string,ConsoleOutput = True, Iam = AC.Iam_Normal ,LocalVars = Non


# Getting rid of not interpretable brackets
# string = NonInterpreteableBracketReplace(string)
# string = NonInterpretableBracketReplace(string)


# Add multiplication signs where a human might leave them out
Expand Down Expand Up @@ -421,7 +421,7 @@ def Derivative_and_IndefiniteIntegral_Parser(string):
break
return string

def NonInterpreteableBracketReplace(string):
def NonInterpretableBracketReplace(string):
for i in ART.l_pairs_brackets_not_interpretable:
string = string.replace(i[0],"(")
string = string.replace(i[1],")")
Expand Down Expand Up @@ -480,6 +480,8 @@ def AstusParseInverse(string, Validate=False):
string = Replace(string,ART.n_standard_integrals)
string = Replace(string,ART.LIST_r_s_scripts,1,0)
string = Replace(string,ART.LIST_n_invertable,1,0)
for i in ART.n_greek_letters_nospace:
string = re.sub(r"(?<!\w){}(?!\w)".format(i[1]),i[0],string)

#string = string.replace(" * "," · ")

Expand Down Expand Up @@ -521,8 +523,7 @@ def number_shaver(ch,
else '0' + mat.group(3) ):
return expr.sub(repl,ch)

#FEATURE: Add decimal seperators to the displayed text in the calculator tab (only the text of the item, not any text of the AMaSObject)
# Do this by making a RegEx that matches with the end of the number (ANY symbol other than a number) and makes sure that there is no point at the start of the "number"

def Digit_Grouping(text):
text_org = text
try:
Expand All @@ -538,7 +539,7 @@ def Digit_Grouping(text):
text = ".".join(textparts)
return text
except common_exceptions:
NC(4,"Could not apply thousand seperators.",exc=sys.exc_info(),func="Digit_Grouping",input=text_org)
NC(4,"Could not apply thousand separators.",exc=sys.exc_info(),func="Digit_Grouping",input=text_org)
return text_org
# -----------------------------------------------------------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion AMaDiA_Files/AMaDiA_Options_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def setupUi(self, AMaDiA_Options):
self.line_5.setObjectName("line_5")
self.gridLayout_4.addWidget(self.line_5, 18, 0, 1, 1)
self.cb_U_EnableUnits = QtWidgets.QCheckBox(self.L_O)
self.cb_U_EnableUnits.setChecked(True)
self.cb_U_EnableUnits.setObjectName("cb_U_EnableUnits")
self.gridLayout_4.addWidget(self.cb_U_EnableUnits, 15, 0, 1, 1)
self.line_17 = QtWidgets.QFrame(self.L_O)
Expand Down Expand Up @@ -307,7 +308,7 @@ def setupUi(self, AMaDiA_Options):
AMaDiA_Options.setCentralWidget(self.centralwidget)

self.retranslateUi(AMaDiA_Options)
self.tabWidget.setCurrentIndex(1)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(AMaDiA_Options)

def retranslateUi(self, AMaDiA_Options):
Expand Down
5 changes: 4 additions & 1 deletion AMaDiA_Files/AMaDiA_Options_UI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<item row="0" column="0">
<widget class="MTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_Options">
<attribute name="title">
Expand Down Expand Up @@ -144,6 +144,9 @@ For example m is no longer a variable but instead &quot;meter&quot;.</string>
<property name="text">
<string>Enable Units</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="0">
Expand Down
8 changes: 4 additions & 4 deletions AMaDiA_Files/AMaDiA_ReplacementTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
l_pairs_special_I_D_Unicode = [["∫","d","Integral("],["d(",")/d","diff("],["∂(",")/∂","diff("]]

l_pairs_special = [["sqrt(",")"],["√(",")"]]
l_seperators = [',']
l_separators = [',']

LIST_l_normal_pairs = [l_pairs_brackets , l_pairs_special_I_D_all_Integrals , l_pairs_special]
LIST_l_normal_pairs_Unicode = [l_pairs_brackets , l_pairs_special_I_D_Unicode , l_pairs_special]
Expand Down Expand Up @@ -149,16 +149,16 @@
n_constants = [["\u03c0"," pi "],["∞"," oo "]]
n_operators = [["^","**"],["·","*"]]
n_operators_special = [["√","sqrt"],["∫","Integral"]]
n_operators_notinv = [["–","-"],["—","-"],["×","*"],["÷","/"],["/°","*(360/pi/2)"],["°","/(360/pi/2)"]]
n_operators_notinv = [["–","-"],["—","-"],["×","*"],["÷","/"],["°C","degC"],["°F","*5/9*degC-32*5/9*degC"],["/°","*(360/pi/2)"],["°","/(360/pi/2)"]]
n_operators_dual = [["±","+","-"],["∓","-","+"]]
n_space = [[" "," "]]

n_priority_Invertable = [["/°","*(360/pi/2)"],["°","/(360/pi/2)"]]
n_priority_Invertable = [["°C","*degC"],["°C","degC"],["°F","*5/9*degC-32*5/9*degC"],["/°","*(360/pi/2)"],["°","/(360/pi/2)"]]

LIST_n_all = [n_standard_integrals , n_greek_letters_nospace , n_constants , n_operators , n_operators_special , n_operators_notinv , n_space]

n_constants_nospace = [["π"," pi "]]
LIST_n_invertable = [n_priority_Invertable , n_greek_letters_nospace , n_constants_nospace , n_operators , n_operators_special]
LIST_n_invertable = [n_priority_Invertable , n_operators , n_operators_special]
# ---------------------------------- Special Replacements s_ ----------------------------------

s_constants_math = [["i"," I "],["e"," E "]]
Expand Down
6 changes: 3 additions & 3 deletions AMaDiA_Files/AMaDiA_SystemControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, parent = None):
self.setupUi(self)
self.TopBar = AGeMain.TopBar_Widget(self,False)
self.ControlSystems_tabWidget.setCornerWidget(self.TopBar, QtCore.Qt.TopRightCorner)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True,IncludeAdvancedCB=True)

self.standardSize = (906, 634)
self.resize(*self.standardSize)
Expand Down Expand Up @@ -475,8 +475,8 @@ def ControlSystems_1_System_Display_LaTeX(self,sysObject):
NC(exc=sys.exc_info(),func="AMaDiA_Main_Window.ControlSystems_1_System_Display_LaTeX",win=self.windowTitle(),input=str(sysObject.sys)).send()

def ControlSystems_4_Dirty_Display(self):
if not QtWidgets.QApplication.instance().optionWindow.cb_O_AdvancedMode.isChecked():
NC(3,"This is the \"danger zone\"!\nPlease activate Advanced Mode to confirm that you know what you are doing!",func="AMaDiA_Main_Window.ControlSystems_4_Dirty_Display",win=str(self.windowTitle()),input="Advanced Mode: {}".format(str(QtWidgets.QApplication.instance().optionWindow.cb_O_AdvancedMode.isChecked()))).send()
if not QtWidgets.QApplication.instance().advanced_mode:
NC(3,"This is the \"danger zone\"!\nPlease activate Advanced Mode to confirm that you know what you are doing!",func="AMaDiA_Main_Window.ControlSystems_4_Dirty_Display",win=str(self.windowTitle()),input="Advanced Mode: {}".format(str(QtWidgets.QApplication.instance().advanced_mode))).send()
else:
self.ControlSystems_tabWidget.setCurrentIndex(1)
input_text = "from External_Libraries.python_control_master.control import * \nglobal sys1\nglobal u\nu=\"\"\n" + self.ControlSystems_4_Dirty_Input.toPlainText()
Expand Down
6 changes: 3 additions & 3 deletions AMaDiA_Files/AMaDiA_Widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def eventFilter(self, source, event):
if source.itemAt(event.pos()).data(100).LaTeX_E != "Not converted yet" and source.itemAt(event.pos()).data(100).LaTeX_E != "Could not convert":
action = menu.addAction('Copy LaTeX Equation')
action.triggered.connect(lambda: self.action_H_Copy_LaTeX_E(source,event))
if QtWidgets.QApplication.instance().optionWindow.cb_O_AdvancedMode.isChecked():
if QtWidgets.QApplication.instance().advanced_mode:
action = menu.addAction('+ Copy Input')
action.triggered.connect(lambda: self.action_H_Copy_Input(source,event))
action = menu.addAction('+ Copy cString')
Expand All @@ -306,10 +306,10 @@ def eventFilter(self, source, event):
if source.itemAt(event.pos()).data(100).plottable :
action = menu.addAction('New Plot')
action.triggered.connect(lambda: self.action_H_New_Plot(source,event))
elif QtWidgets.QApplication.instance().optionWindow.cb_O_AdvancedMode.isChecked() :
elif QtWidgets.QApplication.instance().advanced_mode :
action = menu.addAction('+ New Plot')
action.triggered.connect(lambda: self.action_H_New_Plot(source,event))
if source.itemAt(event.pos()).data(100).plot_data_exists and QtWidgets.QApplication.instance().optionWindow.cb_O_AdvancedMode.isChecked():
if source.itemAt(event.pos()).data(100).plot_data_exists and QtWidgets.QApplication.instance().advanced_mode:
menu.addSeparator()
action = menu.addAction('+ Copy x Values')
action.triggered.connect(lambda: self.action_H_Copy_x_Values(source,event))
Expand Down
14 changes: 14 additions & 0 deletions Patchlog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,17 @@ v0.16.2.4: Number Grouping
++ For example 5000666.12345 is displayed as 5,000,666.12345
++ This only influences the displayed text of the items in the calculator history and does not change anything else

v0.16.3: Fahrenheit to Celsius
+ Updated AGeLib to v1.0.3
++ This makes alt+A the application wide shortcut for the advanced mode
++ The control window has the new advanced mode checkbox in the top bar
++ All instances where the advanced mode is relevant now ask the application instead of the options window
+ °F will now automatically be convert to °C
++ Sympy does not support temperatures so I added the conversion formula to the replacement tables
+++ Due to this an inverse conversion is not easily possible
+++ °C is recognized as a variable which means that one must be careful when solving for unknowns
+ Empty inputs are now recognized by AMaS and have a special error message
+ Units are now enabled by default
+ Inverse parsing of Greek letters now only converts them if they are not part of another word
+ Fixed some typos

0 comments on commit 2723c32

Please sign in to comment.