netherknight Posted July 9, 2019 Share Posted July 9, 2019 (edited) Hi everyone, I hope someone can help me. I have a rather length piece of code set up in python that works great in 16.5. However I'd like to make the switch to 17.5 The error's I'm getting are: Error Python error: Traceback (most recent call last): File "", line 221, in File "", line 191, in newyarn File "", line 179, in poly2polys File "", line 122, in strands TypeError: slice indices must be integers or None or have an __index__ method Are these easy to fix changes, or has there been a big change between versions? Edited July 10, 2019 by netherknight Quote Link to comment Share on other sites More sharing options...
Atom Posted July 9, 2019 Share Posted July 9, 2019 (edited) You might want to think about how you are handling all those globals. Types are getting skewed. If you actually print the type of mushheight, you'll discover that it is a float, not an int and thus can't be used for array slicing. Edited July 9, 2019 by Atom Quote Link to comment Share on other sites More sharing options...
netherknight Posted July 9, 2019 Author Share Posted July 9, 2019 Ok sue that makes sense, though it seems odd this worked in 16.5 Is there an elagant way of adjusting without needing to rewrite everything? because even if I convert line 122 and 123 to ints rather than floats, we still run into issues further along the code. Quote Link to comment Share on other sites More sharing options...
Atom Posted July 9, 2019 Share Posted July 9, 2019 (edited) I set line # 213 to mushheight = int(np.floor(mushheight0*len(vertices))+1) And line # 136 to a constant. hairEnd=0.5 #[[zs[np.minimum(np.random.choice(np.arange(hairStart[i]+3*skip//2,hairStart[i]+2*skip)),len(zs)-1)]] for i in np.arange(len(iis))] This caused your code to work on H17.5, for me. My guess is that some of the np (numpy) functions are returning floats instead of ints, now...? Edited July 9, 2019 by Atom Quote Link to comment Share on other sites More sharing options...
netherknight Posted July 9, 2019 Author Share Posted July 9, 2019 Yes!! That does work, intresting that there might be a change in numpy Thank you Atom! I'm going to see if I can rework it but this will help immensly for the time being! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.