Skip to content
Snippets Groups Projects
Commit 1c0cd91f authored by Antonio MATTAR's avatar Antonio MATTAR
Browse files

-Added save images option to beta_reduction

parent 5c7f0842
No related branches found
No related tags found
No related merge requests found
...@@ -195,7 +195,6 @@ import image_maker ...@@ -195,7 +195,6 @@ import image_maker
image_counter = 0 image_counter = 0
def captureImage(terme, path, counter=True, date= True): def captureImage(terme, path, counter=True, date= True):
global image_counter global image_counter
print(counter)
if type(counter) == bool and counter: if type(counter) == bool and counter:
if path == None: if path == None:
image_maker.saveImage(image_maker.createImage(terme),str(image_counter),None,date) image_maker.saveImage(image_maker.createImage(terme),str(image_counter),None,date)
...@@ -211,11 +210,14 @@ def captureImage(terme, path, counter=True, date= True): ...@@ -211,11 +210,14 @@ def captureImage(terme, path, counter=True, date= True):
def beta_reduction_totale(terme, path, saveImages=True): def beta_reduction_totale(terme, path, saveImages=True):
if saveImages == False: save_image_choice = input("Voulez vous sauvegarder les images (y/n)? ")
while save_image_choice not in ["y","n"]:
save_image_choice = input("Voulez vous sauvegarder les images (y/n)? ")
if save_image_choice == "n":
if beta_reduction(terme) != None: if beta_reduction(terme) != None:
return beta_reduction_totale(beta_reduction(terme), path, False) return beta_reduction_totale(beta_reduction(terme), path, False)
return (terme) return (terme)
else: elif save_image_choice == "y":
if path == None: if path == None:
captureImage(terme, None) captureImage(terme, None)
else: else:
...@@ -224,6 +226,7 @@ def beta_reduction_totale(terme, path, saveImages=True): ...@@ -224,6 +226,7 @@ def beta_reduction_totale(terme, path, saveImages=True):
return beta_reduction_totale(beta_reduction(terme), path) return beta_reduction_totale(beta_reduction(terme), path)
return (terme) return (terme)
numbers_to_letters = { numbers_to_letters = {
0:'x', 0:'x',
1:'y', 1:'y',
...@@ -432,7 +435,7 @@ def beta_reduction_choice_n(terme,n): ...@@ -432,7 +435,7 @@ def beta_reduction_choice_n(terme,n):
def beta_reduction_interactive(terme, at): def beta_reduction_interactive(terme, at):
global counters global counters
if at != None: if at != None:
print(annotated_to_string(at)) # print(annotated_to_string(at))
choice = int(input("Choose a beta reduction: ")) choice = int(input("Choose a beta reduction: "))
while choice <= 0 or choice > counters: while choice <= 0 or choice > counters:
print("Invalid choice") print("Invalid choice")
...@@ -457,7 +460,7 @@ def beta_reduction_interactive_totale(terme,path): ...@@ -457,7 +460,7 @@ def beta_reduction_interactive_totale(terme,path):
save_image_choice = int(input("Save image? (1 for yes, 0 for no): ")) save_image_choice = int(input("Save image? (1 for yes, 0 for no): "))
if save_image_choice == 1: if save_image_choice == 1:
if beta_reduction((terme)) != None: if beta_reduction((terme)) != None:
print(to_string(terme)) # print(to_string(terme))
at = (annotate_beta_reduction((terme))) at = (annotate_beta_reduction((terme)))
captureImage(at,path) captureImage(at,path)
choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non ")) choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non "))
...@@ -472,7 +475,7 @@ def beta_reduction_interactive_totale(terme,path): ...@@ -472,7 +475,7 @@ def beta_reduction_interactive_totale(terme,path):
return (terme) return (terme)
else: else:
if beta_reduction((terme)) != None: if beta_reduction((terme)) != None:
print(to_string(terme)) # print(to_string(terme))
at = (annotate_beta_reduction((terme))) at = (annotate_beta_reduction((terme)))
choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non ")) choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non "))
if choix==1: if choix==1:
......
...@@ -24,15 +24,16 @@ arithmetic_operations_options = { ...@@ -24,15 +24,16 @@ arithmetic_operations_options = {
1: 'Addition', 1: 'Addition',
2: 'Subtraction', 2: 'Subtraction',
3: 'Multiplication', 3: 'Multiplication',
4: 'power', 4: 'Power',
5: 'successor', 5: 'Successor',
6: 'predecessor', 6: 'Predecessor',
7: 'Back', 7: 'Back',
} }
choice_number_representation= { choice_number_representation= {
1: 'integer numbers (church representation)', 1: 'Integer numbers (church representation)',
2: 'relative numbers' 2: 'Relative numbers',
3: 'Back'
} }
#vide un repertoire #vide un repertoire
def delete_images(path): def delete_images(path):
...@@ -105,6 +106,8 @@ def run_show_numbers(path): ...@@ -105,6 +106,8 @@ def run_show_numbers(path):
save_image_choice = input('Invalid choice. Do you want to save the image? (y/n): ') save_image_choice = input('Invalid choice. Do you want to save the image? (y/n): ')
if save_image_choice == 'y': if save_image_choice == 'y':
logic.captureImage(t,path,'ENTIER-RELATIF-'+str(terme),False) logic.captureImage(t,path,'ENTIER-RELATIF-'+str(terme),False)
elif choice==3:
run_main_menu()
...@@ -205,3 +208,5 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): ...@@ -205,3 +208,5 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'):
run_main_menu() run_main_menu()
run_main_menu() run_main_menu()
input()
\ No newline at end of file
...@@ -83,4 +83,6 @@ from logic import * ...@@ -83,4 +83,6 @@ from logic import *
import parsing import parsing
#print(annotated_to_string(x)) #print(annotated_to_string(x))
#beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: "))) #beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: ")))
beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: "))) # beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: ")))
\ No newline at end of file
### ADD SAVE IMAGE CHOICE FOR BETA REDUCTION!!!!
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment