omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Insane TypeError on project

    Pythonista
    project typeerror
    3
    4
    2485
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SmartGoat
      SmartGoat last edited by

      Hi everyone, today I’m posting this because I get the most strange bug of my Pythonista experience. I was experiencing with neural networks made from scratch (in fact, behaviour of raptor VS sheep) and I get an amazingly simple TypeError in my main.py file (l.131):

      Traceback (most recent call last):
      File "/var/containers/Bundle/Application/2BCE66D1-3EB5-46DC-AFEE-F33C73B6BB37/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/scene.py", line 199, in _draw
      self.update()
      File "/private/var/mobile/Containers/Shared/AppGroup/D48F6FDD-3F34-40EB-9497-17B2560BB120/Pythonista3/Documents/Neural Networks/RAPTOR-MOUTON/main.py", line 232, in update input = self.get_input(agent) File "/private/var/mobile/Containers/Shared/AppGroup/D48F6FDD-3F34-40EB-9497-17B2560BB120/Pythonista3/Documents/Neural Networks/RAPTOR-MOUTON/main.py", line 131, in get_input obj.position[0], obj.position[1])
      TypeError: 'NoneType' object is not iterable
      

      I get a NoneType object in a list, but I tried to debunk it in every way without seeing a single “None”..... I’m despaired...
      I tried one hundred times to resolve this, but even when I check before execution If BOTH positions (of f.vision_cut() args - > l.130) aren’t NoneType objects, I get the same error. Here is below the link of my project, with images and others scripts included in the project. Please just try and see how weird it is.
      https://www.dropbox.com/sh/ryf9tk90b1vtu38/AADJ_Xu6UIDstZJc6HEJ6RCxa?dl=0

      Thanks in advance for every answer !
      Cordially,
      SmartGoat

      P.S: I don’t have included comments, tell it to me if you absolutely need them to solve the bug, and I’ll make commented versions of my code. Have a nice day/night !

      1 Reply Last reply Reply Quote 0
      • jgoalby
        jgoalby last edited by jgoalby

        I know what is causing the error but don’t know exactly why. In your funcs.py module, you have a vision_cut function. It doesn’t have a default return. It has elif that are not always going to be entered.

        So if no condition is met I presume python returns None for the tuple which then cannot be unpacked into the two values. This I am not 100% sure of but it seems logical.

        John.

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          Have you tried using the debugger on that line? Or, try

          import pdb
          pdb.pm()
          

          Then print out the various attributes to figure out which one is None.

          If I had to guess, it appears that the error must be two lines before, iterating over self.agents. How about checking self. agents everywhere that agents can be modified:
          * After generate_agents call in setup
          * At start of update

          I.e
          print('value of agents ={}'.format(self.agents))

          If you ever find that self.agents is None instead of [], then something wonky happened!

          1 Reply Last reply Reply Quote 0
          • SmartGoat
            SmartGoat last edited by SmartGoat

            @jgoalby I love you, you found indirectly the error ^^ sometimes the difference in Y axis divided by difference in X axis between two objects was exactly 1, and I didn’t take this case in account in my vision_cut() function, so now i’ve made a little change and it’s now fixed ! Thank you so much for your help, and have a nice day / night !
            @JonB thank you for helping me, but the bug is already fixed, I hope it doesn’t annoy you ^^ good night !

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors