Jump to content
Sign in to follow this  
netherknight

Switch from 16.5 to 17.5 breaks my python code.

Recommended Posts

Posted (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 by netherknight

Share this post


Link to post
Share on other sites
Posted (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.

Untitled-1.jpg

Edited by Atom

Share this post


Link to post
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. 

Share this post


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

Share this post


Link to post
Share on other sites

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! 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×