Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alligators-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Monmege
Alligators-python
Commits
1c0cd91f
Commit
1c0cd91f
authored
2 years ago
by
Antonio MATTAR
Browse files
Options
Downloads
Patches
Plain Diff
-Added save images option to beta_reduction
parent
5c7f0842
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
logic.py
+9
-6
9 additions, 6 deletions
logic.py
main.py
+11
-6
11 additions, 6 deletions
main.py
tests.py
+3
-1
3 additions, 1 deletion
tests.py
with
23 additions
and
13 deletions
logic.py
+
9
−
6
View file @
1c0cd91f
...
@@ -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
)
el
se
:
el
if
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
:
...
...
This diff is collapsed.
Click to expand it.
main.py
+
11
−
6
View file @
1c0cd91f
...
@@ -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
:
'
p
ower
'
,
4
:
'
P
ower
'
,
5
:
'
s
uccessor
'
,
5
:
'
S
uccessor
'
,
6
:
'
p
redecessor
'
,
6
:
'
P
redecessor
'
,
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
This diff is collapsed.
Click to expand it.
tests.py
+
3
−
1
View file @
1c0cd91f
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment