Skip to content

Commit d496533

Browse files
authored
Sanity check (#373)
* add map repr * fix parameter counter repr * fix extra_parameter with include empty * handle extra_param when include empty is emtpy * sort the param when adding parameters * avoid duplicate parameter on tiling * fix sanity_check test to use new assumptions * reactivate sanity check test * reactivating a bunch of test that are actually passing
1 parent b4cbc94 commit d496533

File tree

10 files changed

+560
-496
lines changed

10 files changed

+560
-496
lines changed

tests/algorithms/test_enumeration.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def test_not_verified(self, enum_with_list_req, onebyone_enum, enum_with_crossin
252252
)
253253
assert not MonotoneTreeEnumeration(forest_tiling).verified()
254254

255-
@pytest.mark.xfail
256255
def test_get_genf(self, enum_verified):
257256
x = sympy.Symbol("x")
258257
expected_gf = -(
@@ -272,7 +271,6 @@ def test_get_genf(self, enum_verified):
272271
expected_gf = -1 / ((x - 1) * (x / (x - 1) + 1))
273272
assert sympy.simplify(enum_no_start.get_genf() - expected_gf) == 0
274273

275-
@pytest.mark.xfail
276274
def test_get_genf_simple(self):
277275
t = Tiling(
278276
obstructions=[
@@ -285,7 +283,6 @@ def test_get_genf_simple(self):
285283
assert enum.verified()
286284
assert sympy.simplify(enum.get_genf() - sympy.sympify("1/(1-2*x)")) == 0
287285

288-
@pytest.mark.xfail
289286
def test_with_finite_monotone_cell(self):
290287
t = Tiling(
291288
obstructions=[
@@ -300,7 +297,6 @@ def test_with_finite_monotone_cell(self):
300297
assert enum.verified()
301298
assert enum.get_genf().expand() == sympy.sympify("1+2*x+2*x**2")
302299

303-
@pytest.mark.xfail
304300
def test_with_finite_monotone_cell2(self):
305301
t = Tiling(
306302
obstructions=[
@@ -367,7 +363,6 @@ def test_interleave_fixed_lengths(self, enum_verified):
367363
+ 20 * x ** 11 * dummy_var ** 3 * cell_var ** 3
368364
)
369365

370-
@pytest.mark.xfail
371366
def test_genf_with_req(self):
372367
t = Tiling(
373368
obstructions=[
@@ -386,7 +381,6 @@ def test_genf_with_req(self):
386381
terms = [0, 0, 0, 3, 10, 25, 56, 119, 246, 501, 1012]
387382
assert taylor_expand(genf) == terms
388383

389-
@pytest.mark.xfail
390384
def test_genf_with_big_finite_cell(self):
391385
t = Tiling(
392386
obstructions=[
@@ -412,7 +406,6 @@ def test_genf_with_big_finite_cell(self):
412406
+ 20 * x ** 6
413407
)
414408

415-
@pytest.mark.xfail
416409
def test_with_two_reqs(self):
417410
t = Tiling(
418411
obstructions=(
@@ -432,7 +425,6 @@ def test_with_two_reqs(self):
432425
assert enum.verified()
433426
assert taylor_expand(enum.get_genf()) == expected_enum
434427

435-
@pytest.mark.xfail
436428
def test_corner(self):
437429
t = Tiling(
438430
obstructions=(

tests/strategies/test_sanity_check.py

Lines changed: 540 additions & 477 deletions
Large diffs are not rendered by default.

tests/test_bijections.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
from tilings.strategies.sliding import SlidingFactory, SlidingStrategy
2929
from tilings.tilescope import TileScope, TileScopePack
3030

31-
pytestmark = pytest.mark.xfail
32-
3331

3432
def find_bijection_between(
3533
searcher1: CombinatorialSpecificationSearcher,
@@ -151,6 +149,7 @@ def test_bijection_7():
151149
)
152150

153151

152+
@pytest.mark.xfail
154153
def test_bijection_8_cross_domain():
155154
# flake8: noqa
156155
_import_css_example()
@@ -182,6 +181,7 @@ def test_bijection_8_cross_domain():
182181
_bijection_asserter(find_bijection_between(searcher2, searcher1))
183182

184183

184+
@pytest.mark.xfail
185185
def test_bijection_9_cross_domain():
186186
# flake8: noqa
187187
_import_css_example()
@@ -487,6 +487,7 @@ def test_bijection_14_json():
487487
_bijection_asserter(Bijection.from_dict(json.loads(json.dumps(bi.to_jsonable()))))
488488

489489

490+
@pytest.mark.xfail
490491
@pytest.mark.slow
491492
def test_bijection_15_fusion():
492493
pack = TileScopePack.row_and_col_placements(row_only=True).make_fusion(tracked=True)
@@ -799,6 +800,7 @@ def test_bijection_15_fusion():
799800
)
800801

801802

803+
@pytest.mark.xfail
802804
def test_bijection_16_fusion_json():
803805
pack = TileScopePack(
804806
initial_strats=[strat.FactorFactory()],
@@ -828,6 +830,7 @@ def test_bijection_16_fusion_json():
828830
_bijection_asserter(bi_from_dict)
829831

830832

833+
@pytest.mark.xfail
831834
def test_atom_assumption_path_mismatch():
832835
path1 = [
833836
(
@@ -1278,6 +1281,7 @@ def test_atom_assumption_path_mismatch():
12781281
).assumptions_match_down_to_atom()
12791282

12801283

1284+
@pytest.mark.xfail
12811285
def test_atom_assumption_path_match():
12821286
path1 = [
12831287
(

tests/test_tilescope.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class ComponentFusionStrategy:
1818
pass
1919

2020

21-
pytestmark = pytest.mark.xfail
22-
2321
point_placements = TileScopePack.point_placements()
2422
all_the_strategies_verify_database = TileScopePack.all_the_strategies().make_database()
2523
all_the_strategies_fusion = TileScopePack.all_the_strategies().make_fusion(
@@ -106,6 +104,7 @@ def test_132_321_genf():
106104
]
107105

108106

107+
@pytest.mark.xfail
109108
@pytest.mark.timeout(20)
110109
def test_123():
111110
searcher = TileScope((Perm((0, 1, 2)),), point_placements_fusion)
@@ -120,6 +119,7 @@ def test_123_with_db():
120119
assert isinstance(spec, CombinatorialSpecification)
121120

122121

122+
@pytest.mark.xfail
123123
@pytest.mark.timeout(20)
124124
def test_1342_1423():
125125
point_placements_component_fusion = point_placements.make_fusion(
@@ -305,6 +305,7 @@ def test_expansion():
305305
spec = spec.expand_verified()
306306

307307

308+
@pytest.mark.xfail
308309
@pytest.mark.timeout(30)
309310
def test_domino():
310311
domino = Tiling(
@@ -383,6 +384,7 @@ def forest_expansion():
383384
]
384385

385386

387+
@pytest.mark.xfail
386388
def test_guided_searcher():
387389
tilescope = TileScope(
388390
"123", TileScopePack.point_placements().make_fusion(tracked=False)

tests/test_tiling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,6 @@ def test_is_atom():
23512351
assert not empty_set.is_atom()
23522352

23532353

2354-
@pytest.mark.xfail
23552354
class TestGetGenf:
23562355
"""
23572356
Group all the test regarding getting the generating function for a tiling.

tilings/map.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ def __str__(self) -> str:
404404
s += f" col map: {{{col_str}}}"
405405
return s
406406

407+
def __repr__(self) -> str:
408+
return f"{self.__class__.__name__}({self._row_map!r}, {self._col_map!r})"
409+
407410
def __eq__(self, other: object) -> bool:
408411
if not isinstance(other, RowColMap):
409412
return NotImplemented

tilings/parameter_counter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __hash__(self) -> int:
104104
return hash((self.tiling, self.map))
105105

106106
def __repr__(self) -> str:
107-
return f"{self.__class__.__name__}({self.tiling!r}), {self.map!r})"
107+
return f"{self.__class__.__name__}({self.tiling!r}, {self.map!r})"
108108

109109
def __str__(self):
110110
map_str = " " + str(self.map).replace("\n", "\n ")

tilings/strategies/requirement_placement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ def extra_parameters(
8888
raise StrategyDoesNotApply("Strategy does not apply")
8989
algo = self.placement_class(comb_class)
9090
extra_parameters: Tuple[Dict[str, str], ...] = tuple({} for _ in children)
91-
if self.include_empty:
91+
if self.include_empty and not children[0].is_empty():
9292
child = children[0]
9393
for parameter in comb_class.parameters:
9494
mapped_parameter = parameter.add_obstructions_and_requirements(
95-
child.obstructions, []
95+
self.gps, []
9696
).apply_row_col_map(child.forward_map)
9797
parent_var = comb_class.get_parameter_name(parameter)
9898
child_var = child.get_parameter_name(mapped_parameter)

tilings/tiling.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(
122122
# Set of requirement lists
123123
self._requirements = Tiling.sort_requirements(requirements)
124124
# Set of parameters
125-
self._parameters = tuple(sorted(parameters))
125+
self._parameters = tuple(sorted(set(parameters)))
126126

127127
# Simplify the set of obstructions and the set of requirement lists
128128
if simplify:
@@ -615,10 +615,11 @@ def add_parameter(self, parameter: ParameterCounter) -> "Tiling":
615615

616616
def add_parameters(self, parameters: Iterable[ParameterCounter]) -> "Tiling":
617617
"""Returns a new tiling with the added parameters."""
618+
sorted_params = sorted(chain(self._parameters, parameters))
618619
tiling = Tiling(
619620
self._obstructions,
620621
self._requirements,
621-
self._parameters + tuple(parameters),
622+
sorted_params,
622623
remove_empty_rows_and_cols=False,
623624
derive_empty=False,
624625
simplify=False,

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ commands = pytest
2626

2727
[pytest]
2828
; Should remove the ignore and add the readme to test path before merging into develop.
29-
addopts = --doctest-modules --doctest-ignore-import-errors --ignore=tests/algorithms/test_sliding_alg.py --ignore=tests/test_assumptions.py --ignore=tests/strategies/test_assumtions_splitting.py --ignore=tests/strategies/test_encoding.py --ignore=tests/strategies/test_reverse_fusion.py --ignore=tests/strategies/test_sanity_check.py --ignore=tests/strategies/test_constructor_equiv.py --ignore=tests/strategies/test_factors.py --ignore=tests/strategies/test_fusion_strat.py --ignore=tests/strategies/test_inferral.py --ignore=tests/strategies/test_rearrange_assumption.py --ignore=tests/strategies/test_symmetries.py --ignore=tests/strategies/test_verification.py
29+
addopts = --doctest-modules --doctest-ignore-import-errors --ignore=tests/algorithms/test_sliding_alg.py --ignore=tests/test_assumptions.py --ignore=tests/strategies/test_assumtions_splitting.py --ignore=tests/strategies/test_encoding.py --ignore=tests/strategies/test_reverse_fusion.py --ignore=tests/strategies/test_constructor_equiv.py --ignore=tests/strategies/test_factors.py --ignore=tests/strategies/test_fusion_strat.py --ignore=tests/strategies/test_inferral.py --ignore=tests/strategies/test_rearrange_assumption.py --ignore=tests/strategies/test_symmetries.py --ignore=tests/strategies/test_verification.py
3030
testpaths = tests tilings
3131
markers = slow: marks tests as slow (deselect with '-m "not slow"')
3232
doctest_optionflags= NORMALIZE_WHITESPACE

0 commit comments

Comments
 (0)