Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arc
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Buckworth, Titus Frederick Christian C
arc
Commits
023eff7d
Commit
023eff7d
authored
3 months ago
by
tbuckworth
Browse files
Options
Downloads
Patches
Plain Diff
created solution_test.py
parent
b0c27334
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
json_tests.py
+5
-5
5 additions, 5 deletions
json_tests.py
main.py
+3
-2
3 additions, 2 deletions
main.py
prolog/solution_1.pl
+0
-5
0 additions, 5 deletions
prolog/solution_1.pl
solution_tests.py
+33
-0
33 additions, 0 deletions
solution_tests.py
with
41 additions
and
12 deletions
json_tests.py
+
5
−
5
View file @
023eff7d
...
@@ -10,7 +10,7 @@ from task import Task
...
@@ -10,7 +10,7 @@ from task import Task
class
TaskTester
(
unittest
.
TestCase
):
class
TaskTester
(
unittest
.
TestCase
):
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
cls
.
task_dict
=
load_task
(
"
data/training/d4f3cd78.json
"
)
cls
.
task_dict
=
load_task
(
)
#
"data/training/d4f3cd78.json")
cls
.
task
=
Task
(
cls
.
task_dict
)
cls
.
task
=
Task
(
cls
.
task_dict
)
# Example of accessing input/output grids for the first example
# Example of accessing input/output grids for the first example
cls
.
output_grid
=
cls
.
task
.
train_examples
[
0
].
output_grid
.
grid
cls
.
output_grid
=
cls
.
task
.
train_examples
[
0
].
output_grid
.
grid
...
@@ -29,13 +29,13 @@ class TaskTester(unittest.TestCase):
...
@@ -29,13 +29,13 @@ class TaskTester(unittest.TestCase):
self
.
assertTrue
((
out_grid
==
self
.
output_grid
).
all
())
self
.
assertTrue
((
out_grid
==
self
.
output_grid
).
all
())
def
test_task_class
(
self
):
def
test_task_class
(
self
):
solution
=
"
solution_
2
"
solution
=
"
solution_
1
"
res
=
self
.
task
.
try_solution
(
solution
)
res
=
self
.
task
.
try_solution
(
solution
)
self
.
assertTrue
(
res
)
self
.
assertTrue
(
res
)
def
test_task_empty
(
self
):
#
def test_task_empty(self):
res
=
self
.
task
.
try_solution
(
"
empty_solution
"
)
#
res = self.task.try_solution("empty_solution")
self
.
assertFalse
(
res
)
#
self.assertFalse(res)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
unittest
.
main
()
This diff is collapsed.
Click to expand it.
main.py
+
3
−
2
View file @
023eff7d
...
@@ -8,9 +8,10 @@ import matplotlib.pyplot as plt
...
@@ -8,9 +8,10 @@ import matplotlib.pyplot as plt
import
subprocess
import
subprocess
tasks
=
{
tasks
=
{
"
lines
"
:
"
0b148d64.json
"
,
#
"lines": "0b148d64.json",
"
grid
s
"
:
"
90f3ed37
.json
"
,
"
line
s
"
:
"
0a938d79
.json
"
,
"
pour
"
:
"
d4f3cd78.json
"
,
"
pour
"
:
"
d4f3cd78.json
"
,
"
grids
"
:
"
90f3ed37.json
"
,
"
cross
"
:
"
e21d9049.json
"
,
"
cross
"
:
"
e21d9049.json
"
,
"
stripes
"
:
"
f8c80d96.json
"
"
stripes
"
:
"
f8c80d96.json
"
}
}
...
...
This diff is collapsed.
Click to expand it.
prolog/solution_1.pl
+
0
−
5
View file @
023eff7d
all_rows
(
Rs
):-
all_rows
(
Rs
):-
setof
(
R
,
C
^
Colour
^
input_colour
(
R
,
C
,
Colour
),
Rs
).
setof
(
R
,
C
^
Colour
^
input_colour
(
R
,
C
,
Colour
),
Rs
).
all_cols
(
Cs
):-
all_cols
(
Cs
):-
setof
(
C
,
R
^
Colour
^
input_colour
(
R
,
C
,
Colour
),
Cs
).
setof
(
C
,
R
^
Colour
^
input_colour
(
R
,
C
,
Colour
),
Cs
).
row
(
R
):-
row
(
R
):-
all_rows
(
Rs
),
all_rows
(
Rs
),
member
(
R
,
Rs
).
member
(
R
,
Rs
).
...
...
This diff is collapsed.
Click to expand it.
solution_tests.py
0 → 100644
+
33
−
0
View file @
023eff7d
import
copy
import
unittest
import
numpy
as
np
from
main
import
load_task
,
FOL2grid
,
FOL2prolog
,
prolog2FOL_array
,
tasks
from
task
import
Task
class
TaskTester
(
unittest
.
TestCase
):
# @classmethod
# def setUpClass(cls):
# cls.task_dict = load_task("data/training/d4f3cd78.json")
# cls.task = Task(cls.task_dict)
# # Example of accessing input/output grids for the first example
# cls.output_grid = cls.task.train_examples[0].output_grid.grid
# cls.out_preds = cls.task.train_examples[0].output_grid.preds
def
try_solution
(
self
,
task_file
,
solution
):
task_dict
=
load_task
(
f
"
data/training/
{
task_file
}
"
)
task
=
Task
(
task_dict
)
res
=
task
.
try_solution
(
solution
)
self
.
assertTrue
(
res
)
def
test_solution_1
(
self
):
self
.
try_solution
(
tasks
[
"
lines
"
],
'
solution_1
'
)
def
test_solution_2
(
self
):
self
.
try_solution
(
tasks
[
"
pour
"
],
'
solution_2
'
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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