Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanity check failure #492

Open
christianbean opened this issue Jul 22, 2022 · 2 comments
Open

sanity check failure #492

christianbean opened this issue Jul 22, 2022 · 2 comments

Comments

@christianbean
Copy link
Member

reverse of 'change component assumption in cells (0, 1) to point assumption'
+-+                                                         +-+                                                    
|\|                                                      =  |\|                                                    
+-+                                                         +-+                                                    
|1|                                                         |1|                                                    
+-+                                                         +-+                                                    
1: Av+(02341, 02431, 03412, 03421, 12340, 12430, 13420)     1: Av+(02341, 02431, 03412, 03421, 12340, 12430, 13420)
\: Av+(01)                                                  \: Av+(01)                                             
Crossing obstructions:                                      Crossing obstructions:                                 
02341: (0, 0), (0, 0), (0, 0), (0, 1), (0, 0)               02341: (0, 0), (0, 0), (0, 0), (0, 1), (0, 0)          
02431: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)               02431: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)          
02431: (0, 0), (0, 0), (0, 1), (0, 1), (0, 0)               02431: (0, 0), (0, 0), (0, 1), (0, 1), (0, 0)          
03412: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)               03412: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)          
03421: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)               03421: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)          
12340: (0, 0), (0, 0), (0, 0), (0, 1), (0, 0)               12340: (0, 0), (0, 0), (0, 0), (0, 1), (0, 0)          
12430: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)               12430: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)          
12430: (0, 0), (0, 0), (0, 1), (0, 1), (0, 0)               12430: (0, 0), (0, 0), (0, 1), (0, 1), (0, 0)          
13420: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)               13420: (0, 0), (0, 0), (0, 1), (0, 0), (0, 0)          
Requirement 0:                                              Requirement 0:                                         
10: (0, 1), (0, 0)                                          10: (0, 1), (0, 0)                                     
Assumption 0:                                               Assumption 0:                                          
can count points in cell (0, 1)                             can count skew components in cells frozenset({(0, 1)}) 
                                                            Assumption 1:                                          
                                                            can count points in cell (0, 1)                        
{"class_module": "comb_spec_searcher.strategies.rule", "rule_class": "EquivalencePathRule", "rules": [{"class_module": "comb_spec_searcher.strategies.rule", "rule_class": "ReverseRule", "original_rule": {"class_module": "comb_spec_searcher.strategies.rule", "rule_class": "Rule", "comb_class": {"class_module": "tilings.tiling", "comb_class": "Tiling", "obstructions": [{"patt": [0, 1], "pos": [[0, 1], [0, 1]]}, {"patt": [0, 2, 3, 4, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 2, 3, 4, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 1], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 1], [0, 0]]}, {"patt": [0, 3, 4, 1, 2], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 1, 2], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 2, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 2, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [1, 2, 3, 4, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 2, 3, 4, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 1], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 1], [0, 0]]}, {"patt": [1, 3, 4, 2, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 3, 4, 2, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}], "requirements": [[{"patt": [1, 0], "pos": [[0, 1], [0, 0]]}]], "assumptions": [{"class_module": "tilings.assumptions", "assumption": "SkewComponentAssumption", "gps": [{"patt": [0], "pos": [[0, 1]]}]}, {"class_module": "tilings.assumptions", "assumption": "TrackingAssumption", "gps": [{"patt": [0], "pos": [[0, 1]]}]}]}, "children": [{"class_module": "tilings.tiling", "comb_class": "Tiling", "obstructions": [{"patt": [0, 1], "pos": [[0, 1], [0, 1]]}, {"patt": [0, 2, 3, 4, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 2, 3, 4, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 1], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [0, 2, 4, 3, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 1], [0, 0]]}, {"patt": [0, 3, 4, 1, 2], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 1, 2], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 2, 1], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [0, 3, 4, 2, 1], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [1, 2, 3, 4, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 2, 3, 4, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 1], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}, {"patt": [1, 2, 4, 3, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 1], [0, 0]]}, {"patt": [1, 3, 4, 2, 0], "pos": [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]}, {"patt": [1, 3, 4, 2, 0], "pos": [[0, 0], [0, 0], [0, 1], [0, 0], [0, 0]]}], "requirements": [[{"patt": [1, 0], "pos": [[0, 1], [0, 0]]}]], "assumptions": [{"class_module": "tilings.assumptions", "assumption": "TrackingAssumption", "gps": [{"patt": [0], "pos": [[0, 1]]}]}]}], "strategy": {"class_module": "tilings.strategies.rearrange_assumption", "strategy_class": "ComponentToPointAssumptionStrategy", "ignore_parent": false, "inferrable": false, "possibly_empty": false, "workable": false, "assumption": {"class_module": "tilings.assumptions", "assumption": "SkewComponentAssumption", "gps": [{"patt": [0], "pos": [[0, 1]]}]}}}, "idx": 0}]}
Traceback (most recent call last):
  File "garpur-run-load.py", line 14, in <module>
    spec.sanity_check(i)
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/specification.py", line 493, in sanity_check
    if not rule.sanity_check(n):
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/strategies/rule.py", line 543, in sanity_check
    and self._sanity_check_random_sample(n)
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/strategies/rule.py", line 647, in _sanity_check_random_sample
    self.random_sample_object_of_size(n, **possible_parameters[0][0])
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/strategies/rule.py", line 535, in random_sample_object_of_size
    objs = tuple(self.backward_map(subobjs))
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/strategies/rule.py", line 908, in backward_map
    res = (next(rule.backward_map(res)),)
  File "/Users/christianbean/Documents/code/comb_spec_searcher/comb_spec_searcher/strategies/rule.py", line 1044, in backward_map
    assert all(obj is None for obj in objs[1:])
TypeError: 'NoneType' object is not subscriptable
@jaypantone
Copy link
Collaborator

jaypantone commented Jul 26, 2022

I got a similar sanity check error with a different spec

import requests
from comb_spec_searcher import CombinatorialSpecification
from tilings.tilescope import TileScopePack

uri = "https://api.permpal.com/garpur_run/62dffd741b6d843bb59a3f73"
data = requests.get(uri).json()
pack = TileScopePack.from_dict(data["pack"])
spec = CombinatorialSpecification.from_dict(data["specification"])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [3], in <module>
----> 1 spec.sanity_check(1)

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/specification.py:490, in CombinatorialSpecification.sanity_check(self, length)
    488 try:
    489     for n in range(length + 1):
--> 490         if not rule.sanity_check(n):
    491             return False
    492 except NotImplementedError:

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/strategies/rule.py:543, in Rule.sanity_check(self, n)
    538 def sanity_check(self, n: int) -> bool:
    539     try:
    540         return (
    541             self._sanity_check_count(n)
    542             and self._sanity_check_objects(n)
--> 543             and self._sanity_check_random_sample(n)
    544         )
    545     except SanityCheckFailure as e:
    546         raise e

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/strategies/rule.py:647, in Rule._sanity_check_random_sample(self, n)
    645 self.subterms = tuple(child.get_terms for child in self.children)
    646 try:
--> 647     self.random_sample_object_of_size(n, **possible_parameters[0][0])
    648 except NotImplementedError:
    649     # Skipping testing rules that have not implemented random_sampling.
    650     self.subsamplers = tmpsamplers

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/strategies/rule.py:535, in Rule.random_sample_object_of_size(self, n, **parameters)
    531 total_count = self.count_objects_of_size(n=n, **parameters)
    532 subobjs = self.constructor.random_sample_sub_objects(
    533     total_count, self.subsamplers, self.subrecs, n, **parameters
    534 )
--> 535 objs = tuple(self.backward_map(subobjs))
    536 return random.choice(objs)

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/strategies/rule.py:908, in EquivalencePathRule.backward_map(self, objs)
    906 for rule in reversed(self.rules):
    907     try:
--> 908         res = (next(rule.backward_map(res)),)
    909     except StopIteration:
    910         return

File ~/atrap/repos/comb_spec_searcher/comb_spec_searcher/strategies/rule.py:1044, in ReverseRule.backward_map(self, objs)
   1042 if not len(self.original_rule.non_empty_children()) == 1:
   1043     raise NotImplementedError("Cannot map forward for non equivalence rule.")
-> 1044 assert all(obj is None for obj in objs[1:])
   1045 assert objs[0] is not None
   1046 res = self.original_rule.forward_map(objs[0])[self.idx]

TypeError: 'NoneType' object is not subscriptable (key slice(1, None, None))

@jaypantone
Copy link
Collaborator

jaypantone commented Jul 26, 2022

Two more examples:

import requests
from comb_spec_searcher import CombinatorialSpecification
from tilings.tilescope import TileScopePack

uri = "https://api.permpal.com/garpur_run/62e000d667d0aaf5374f1fd5"
data = requests.get(uri).json()
pack = TileScopePack.from_dict(data["pack"])
spec = CombinatorialSpecification.from_dict(data["specification"])
spec.sanity_check(2)
import requests
from comb_spec_searcher import CombinatorialSpecification
from tilings.tilescope import TileScopePack

uri = "https://api.permpal.com/garpur_run/62e004f03a0324176007e7a1"
data = requests.get(uri).json()
pack = TileScopePack.from_dict(data["pack"])
spec = CombinatorialSpecification.from_dict(data["specification"])
spec.sanity_check(3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants