Skip to content

Attribute Error for NQueensProblem in search.ipynb #1308

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

Open
s-m-sharjeel opened this issue Feb 19, 2025 · 0 comments
Open

Attribute Error for NQueensProblem in search.ipynb #1308

s-m-sharjeel opened this issue Feb 19, 2025 · 0 comments

Comments

@s-m-sharjeel
Copy link

s-m-sharjeel commented Feb 19, 2025

AttributeError: 'NQueensProblem' object has no attribute 'graph' in cell [70] of search.ipynb:

%%timeit
depth_first_tree_search(nqp)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[70], line 1
----> 1 get_ipython().run_cell_magic('timeit', '', 'depth_first_tree_search(nqp)\n')

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py:2543, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2541 with self.builtin_trap:
   2542     args = (magic_arg_s, cell)
-> 2543     result = fn(*args, **kwargs)
   2545 # The code below prevents the output from being displayed
   2546 # when using magics with decorator @output_can_be_silenced
   2547 # when the last Python token in the expression is a ';'.
   2548 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\magics\execution.py:1209, in ExecutionMagics.timeit(self, line, cell, local_ns)
   1207 for index in range(0, 10):
   1208     number = 10 ** index
-> 1209     time_number = timer.timeit(number)
   1210     if time_number >= 0.2:
   1211         break

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\magics\execution.py:173, in Timer.timeit(self, number)
    171 gc.disable()
    172 try:
--> 173     timing = self.inner(it, self.timer)
    174 finally:
    175     if gcold:

File <magic-timeit>:1, in inner(_it, _timer)

Cell In[16], line 50, in depth_first_tree_search(problem)
     48 def depth_first_tree_search(problem):
     49     "Search the deepest nodes in the search tree first."
---> 50     iterations, all_node_colors, node = tree_depth_search_for_vis(problem)
     51     return(iterations, all_node_colors, node)

Cell In[16], line 9, in tree_depth_search_for_vis(problem)
      7 iterations = 0
      8 all_node_colors = []
----> 9 node_colors = {k : 'white' for k in problem.graph.nodes()}
     11 #Adding first node to the stack
     12 frontier = [Node(problem.initial)]

AttributeError: 'NQueensProblem' object has no attribute 'graph'
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

1 participant