Skip to content

ENH: Add step argument for linspace (and small fixes for corner cases) - #2945

Closed
seberg wants to merge 2 commits into
numpy:masterfrom
seberg:issue-630
Closed

seberg wants to merge 2 commits into
numpy:masterfrom
seberg:issue-630

Conversation

@seberg

@seberg seberg commented Jan 23, 2013

Copy link
Copy Markdown
Member

This adds a step argument to linspace, however the step argument is only used to determine the integer number of steps. It must be possible to safely determine the number of steps (given floating point accuracy). This was requested in gh-630. Also fixes corner cases where the dtype was not preserved, even though the function supports complex numbers fine.

I kind of like the functionality, but it seems to me like a pure convenience function that, in general code maybe fails unexpectedly (i.e. given very large floats or such), or maybe even works on one computer and not on the next in some examples.

Comment thread numpy/core/function_base.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really where the .. versionadded: goes? it seems counter-intuitive to me but I'm not sure how to check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we've documented versionadded for the case of adding a single parameter, but this is where it normally goes.

The linspace corner cases always returned float, but the rest of the
function did support complex or high precision floating point numbers.
This adds a step argument to linspace, however the step argument is only
used to determine the integer number of steps. It must be possible to safely
determine the number of steps (given floating point accuracy), otherwise
an error raised. This means it cannot be used when start, stop or step are
inaccurate due to previous calculations.

This was requested in numpygh-630.
@seberg

seberg commented Feb 17, 2013

Copy link
Copy Markdown
Member Author

I updated this code, still not sure if it is worth it to provide such a parameter though.

@charris

charris commented Mar 1, 2013

Copy link
Copy Markdown
Member

I don't recall if this was discussed on the list or not.

@seberg

seberg commented Mar 21, 2013

Copy link
Copy Markdown
Member Author

Ah well... closing this until I figured out how to do it less strict... if anyone stumbles on it and has an idea please feel free to post it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants