rougier / numpy-100

100 numpy exercises (with solutions)
MIT License
12.17k stars 5.74k forks source link

Update solution to Q.39 #210

Closed Dimitrije-V closed 5 months ago

Dimitrije-V commented 5 months ago

As I mentioned in the following issue: https://github.com/rougier/numpy-100/issues/209

The solution is not correct for question 39. The question asks for a "vector of size 10 with values ranging from 0 to 1, both excluded". The provided solution generates a vector from 0 to 0.90909091.

This is because the flag endpoint is set to false:

Z = np.linspace(0,1,11,endpoint=False)[1:]

The correct solution is:

Z = np.linspace(0,1,11,endpoint=True)[1:-1]

I can see in other PRs that the .mds are generated by the .ktx file. I've updated the .ktx, but I'm not sure if I need to remove the changes to the .md files.

rougier commented 5 months ago

This does not result on a vector of size 10.

Dimitrije-V commented 5 months ago

This does not result on a vector of size 10.

Sorry, I tend to do these fairly late at night, I meant to paste: Z = np.linspace(0,1,10,endpoint=True)[1:-1]. but accidentally pasted the wrong solution twice.

If you look at the "changed files" section, you'll see that the correct code is in there.

rougier commented 5 months ago

Now it's 8 in size :)

Dimitrije-V commented 5 months ago

You're right! My bad.