Jump to content

Switch from 16.5 to 17.5 breaks my python code.


netherknight

Recommended Posts

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 by netherknight
Link to comment
Share on other sites

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.

Untitled-1.jpg

Edited by Atom
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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 by Atom
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...