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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Monmege
Alligators-python
Commits
e5e9e1cb
Commit
e5e9e1cb
authored
3 years ago
by
Antonio MATTAR
Browse files
Options
Downloads
Patches
Plain Diff
l
parent
426d9c34
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
image_maker.py
+20
-5
20 additions, 5 deletions
image_maker.py
logic.py
+2
-2
2 additions, 2 deletions
logic.py
tests.py
+3
-3
3 additions, 3 deletions
tests.py
with
25 additions
and
10 deletions
image_maker.py
+
20
−
5
View file @
e5e9e1cb
from
ast
import
Raise
from
ast
import
Raise
from
logging
import
exception
from
logging
import
exception
from
pprint
import
pprint
from
PIL
import
Image
from
PIL
import
Image
import
logic
import
logic
import
parser
import
parser
...
@@ -16,6 +17,18 @@ def associateVariableWithColor(variable):
...
@@ -16,6 +17,18 @@ def associateVariableWithColor(variable):
variables_colors_couple
[
str
(
variable
)]
=
colors
[
-
1
]
variables_colors_couple
[
str
(
variable
)]
=
colors
[
-
1
]
colors
.
pop
()
colors
.
pop
()
class
MyImage
:
def
__init__
(
self
,
image
,
boolean
):
self
.
image
=
image
self
.
isEgg
=
boolean
self
.
width
=
self
.
image
.
width
self
.
height
=
self
.
image
.
height
def
resize
(
self
,
given_width
,
given_height
):
if
(
self
.
isEgg
):
self
.
image
=
self
.
image
.
resize
((
min
((
self
.
image
.
width
),
given_width
),
min
((
self
.
image
.
height
),
given_height
)),
Image
.
BICUBIC
)
else
:
self
.
image
=
self
.
image
.
resize
((
given_width
,
given_width
))
def
createVarImage
(
variable
):
def
createVarImage
(
variable
):
assert
(
logic
.
isVariable
(
variable
))
assert
(
logic
.
isVariable
(
variable
))
associateVariableWithColor
(
variable
)
associateVariableWithColor
(
variable
)
...
@@ -43,12 +56,14 @@ def get_concat_h_multi_resize(im_list, resample=Image.BICUBIC):
...
@@ -43,12 +56,14 @@ def get_concat_h_multi_resize(im_list, resample=Image.BICUBIC):
min_height
=
min
(
im
.
height
for
im
in
im_list
)
min_height
=
min
(
im
.
height
for
im
in
im_list
)
im_list_resize
=
[
im
.
resize
((
int
(
im
.
width
*
min_height
/
im
.
height
),
min_height
),
resample
=
resample
)
im_list_resize
=
[
im
.
resize
((
int
(
im
.
width
*
min_height
/
im
.
height
),
min_height
),
resample
=
resample
)
for
im
in
im_list
]
for
im
in
im_list
]
total_width
=
sum
(
im
.
width
for
im
in
im_list_resize
)
min_width
=
min
(
im
.
width
for
im
in
im_list_resize
)
dst
=
Image
.
new
(
'
RGB
'
,
(
total_width
,
min_height
))
space_width
=
int
(
min_width
*
0.25
)
total_width
=
sum
(
im
.
width
for
im
in
im_list_resize
)
+
(
len
(
im_list_resize
)
-
1
)
*
space_width
dst
=
Image
.
new
(
'
RGB
'
,
(
total_width
,
min_height
),
(
255
,
255
,
255
))
pos_x
=
0
pos_x
=
0
for
im
in
im_list_resize
:
for
im
in
im_list_resize
:
dst
.
paste
(
im
,
(
pos_x
,
0
))
dst
.
paste
(
im
,
(
pos_x
,
0
))
pos_x
+=
im
.
width
pos_x
+=
im
.
width
+
space_width
return
dst
return
dst
def
createAppImage
(
terme
):
def
createAppImage
(
terme
):
...
@@ -58,7 +73,7 @@ def createAppImage(terme):
...
@@ -58,7 +73,7 @@ def createAppImage(terme):
im1
=
createImage
(
left
)
im1
=
createImage
(
left
)
im2
=
createImage
(
right
)
im2
=
createImage
(
right
)
space
=
Image
.
open
(
"
figures/space.png
"
)
space
=
Image
.
open
(
"
figures/space.png
"
)
application
=
get_concat_h_multi_resize
([
im1
,
space
,
im2
])
application
=
get_concat_h_multi_resize
([
im1
,
im2
])
return
application
return
application
def
createImage
(
terme
):
def
createImage
(
terme
):
...
...
This diff is collapsed.
Click to expand it.
logic.py
+
2
−
2
View file @
e5e9e1cb
...
@@ -210,11 +210,11 @@ def to_string_var(terme):
...
@@ -210,11 +210,11 @@ def to_string_var(terme):
def
to_string_abs
(
terme
):
def
to_string_abs
(
terme
):
assert
(
isAbstraction
(
terme
)),
'
The argument is not an Abstraction
'
assert
(
isAbstraction
(
terme
)),
'
The argument is not an Abstraction
'
return
"
λ
"
+
to_string
(
getInputFromAbs
(
terme
))
+
"
.
"
+
to_string
(
getOutputFromAbs
(
terme
))
return
"
#
"
+
to_string
(
getInputFromAbs
(
terme
))
+
"
.
"
+
to_string
(
getOutputFromAbs
(
terme
))
def
to_string_app
(
terme
):
def
to_string_app
(
terme
):
assert
(
isApplication
(
terme
)),
'
The argument is not an application
'
assert
(
isApplication
(
terme
)),
'
The argument is not an application
'
return
"
(
"
+
to_string
(
getFirstTerm
(
terme
))
+
"
)
"
+
"
(
"
+
to_string
(
getSecondTerm
(
terme
))
+
"
)
"
return
"
(
"
+
to_string
(
getFirstTerm
(
terme
))
+
"
)
"
+
'
'
+
"
(
"
+
to_string
(
getSecondTerm
(
terme
))
+
"
)
"
def
to_string
(
terme
):
def
to_string
(
terme
):
if
isVariable
(
terme
):
if
isVariable
(
terme
):
return
to_string_var
(
terme
)
return
to_string_var
(
terme
)
...
...
This diff is collapsed.
Click to expand it.
tests.py
+
3
−
3
View file @
e5e9e1cb
from
main
import
*
from
logic
import
*
x
=
new_var
(
freshVar
())
x
=
new_var
(
freshVar
())
y
=
new_var
(
freshVar
())
y
=
new_var
(
freshVar
())
z
=
new_var
(
freshVar
())
z
=
new_var
(
freshVar
())
...
@@ -48,7 +48,7 @@ E = new_app(new_abs(x,new_abs(y,new_app(x,y))),new_abs(y,new_abs(z,new_app(x,z))
...
@@ -48,7 +48,7 @@ E = new_app(new_abs(x,new_abs(y,new_app(x,y))),new_abs(y,new_abs(z,new_app(x,z))
F
=
new_app
(
new_app
(
new_abs
(
x
,
x
),
y
),
new_abs
(
z
,
z
))
F
=
new_app
(
new_app
(
new_abs
(
x
,
x
),
y
),
new_abs
(
z
,
z
))
Y_COMBINATOR
=
new_app
(
new_abs
(
x
,
new_app
(
x
,
x
)),
new_abs
(
y
,
new_app
(
y
,
y
)))
Y_COMBINATOR
=
new_app
(
new_abs
(
x
,
new_app
(
x
,
x
)),
new_abs
(
y
,
new_app
(
y
,
y
)))
print
(
'
/n
'
)
print
(
'
/n
'
)
print
(
E
)
print
(
to_string
(
E
)
)
print
(
'
/n
'
)
print
(
'
/n
'
)
print
((
beta_reduction
(
E
)))
print
((
beta_reduction
(
E
)))
print
(
x
)
print
(
x
)
...
@@ -57,7 +57,7 @@ print(to_string([APP, [APP, [ABS, x, y], y] , z]))
...
@@ -57,7 +57,7 @@ print(to_string([APP, [APP, [ABS, x, y], y] , z]))
# print(beta_reduction_totale(Y_COMBINATOR))
# print(beta_reduction_totale(Y_COMBINATOR))
#############################################################################################################################
#############################################################################################################################
from
parser
import
*
import
parser
A
=
"
#x.(x)(y)
"
A
=
"
#x.(x)(y)
"
print
(
getTermsFromParantheses
(
"
(AAAAAA)(BBBBBBBBB)(CCCCCCCCC)
"
))
print
(
getTermsFromParantheses
(
"
(AAAAAA)(BBBBBBBBB)(CCCCCCCCC)
"
))
print
(
buildTerm
(
A
))
print
(
buildTerm
(
A
))
...
...
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