Python derivativeat

Google: shuffle list python
One of the first results:

Don‘t take me wrong. I really admire that you try to learn python with your own projects. Ofc asking for help on the forum is what you should do if you‘re stuck. But my advice would be starting with tutorials and learning the basics (also possible outside grasshopper). You should learn to help yourself. Sometimes a 1 Minute google search is way faster than asking here.

Google, yes of course. I tried it like this before:

problem%20derivativeat%2004

But, no result. I do not intend to use this forum as a google too. Sorry if it seems like it.
In the previous try I received none

https://docs.python.org/2/library/random.html

I always first search myself and then I ask if I cannot solve it.
random.shuffle(x[, random]) I do not know what to place for x. It just not clear to me, maybe I am slightly not smart enough, but I just do not know how.

Everything is very clearly explained on the internet,

but then when I am at Python Grasshopper it goes something like this

What do you mean by jitter? What are you trying to do ? :confused:

I want to simply ‘shuffle’ the list. But the python code does not work in my case (random.shuffle).

And this is jitter component if you did not know.

Try print thing

1 Like

Jezus, I mean Graham, thank you! This took me some time. :smiley:
So stupid of mine.

:slight_smile: it’s like the difference between
a = sorted(3,1,2)
Returns [1,2,3]
And a = [3,1,2].sort()
Returns None

1 Like

Read here for LOTS more of these

3 Likes

@ForestOwl, do you remember the thread you created about vector.unitize()
You’re making the same mistake here. :slight_smile:

shuffle will modify the list and not create another one.
so not print a but rather print thing

1 Like

@stevebaer,

Can this,
image
be somehow fixed with the Rhino embedded python engine?
I can imagine huge problems can emerge if the coder is careless. :crazy_face:

1 Like

Just tried this in CPython 2.7:

True = False
True == False

True

True = not False
True == False

False

Yes, I read that since at the beginning there were no booleans in python in order to make them backportable they derived True and False from the int() class.

This made them mutable in all Python2 versions. Which was also transferred to IronPython.

I assumed since the C# connection they might have fixed that but unfortunately they didn’t. Perhaps this could be fixed somehow with the embedded engine bind it somehow to .net’s booleans. I don’t know. I’m not familiar with low level programming.

I’m not going to change this behavior.

5 Likes

And I think the Ironpython dev will focus on trying to finish 3.4 before he tries to ´fix’ 2.7

1 Like

I tried PointAt this time too, but it seems I am doing something wrong.
I have the curve length of 84, then I have a list of numbers between 0 and 84.

When I use PointAt, my points fly everywhere. Do you might know why?

problem derivativeat 07.gh (20.6 KB)

I find your code difficult to follow. It is good practice if you don’t use good descriptive names for the variables to place comments explaining what you’re trying to do.

Up to the part where you remove the duplate values from the list and you sort it everything is clear, but after that I really don’t get what you’re trying to do.

Thank you for saying, I changed it.

I hope it is more clear now.

I have a curve and I want to place points on it between 0 and the MAX length of the curve.
I made values and somehow by using PointAt, the points fly away. I do not yet understand why. Do you might know why my points are not on that curve?

problem derivativeat 08.gh (27.0 KB)

The parameter values you are randomly generating are outside the domain of the curve:

1 Like

image

Point at takes parameter not distance on the curve

1 Like

One of the components here does what you want.

It will be a good test to see if it works with multiple length values instead of the slider. I do not remember how I intended it to work :smiley:

I can fix it.

1 Like