Skip to content

Adds endpoint and retstep support for linspace#3675

Merged
jakirkham merged 2 commits intodask:masterfrom
jrbourbeau:update_linspace
Jun 30, 2018
Merged

Adds endpoint and retstep support for linspace#3675
jakirkham merged 2 commits intodask:masterfrom
jrbourbeau:update_linspace

Conversation

@jrbourbeau
Copy link
Member

@jrbourbeau jrbourbeau commented Jun 27, 2018

This PR adds support for the endpoint and retstep keyword arguments to da.linspace. Fixes #3673.

  • Tests added / passed
  • Passes flake8 dask


def linspace(start, stop, num=50, chunks=None, dtype=None):
def linspace(start, stop, num=50, endpoint=True, retstep=False, chunks=None,
dtype=None):
Copy link
Member

Choose a reason for hiding this comment

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

Guess this changes the argument order a little bit. Don't have any insightful thoughts on this ATM, but just checking to see if we should consider doing anything else or more here (warning, deprecation cycle, or nothing).

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch @jakirkham, that was an oversight on my part. I'd be happy to change the order here so that it doesn't break any existing code. However, if we are okay changing the order, I'd be in favor of having the same order as np.linspace followed by chunks. I.e.

def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, chunks=None):

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I kind of like the order you have chosen as well. Moving chunks to the end seems fine to me (assuming we are ok with breaking the order). Let's see if others have any comments on this. Don't expect too much controversy as these are intended to be keyword arguments.

If True, ``stop`` is the last sample. Otherwise, it is not included.
Default is True.

.. versionadded:: 0.18.2
Copy link
Member

Choose a reason for hiding this comment

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

Are we planning on another patch release, @mrocklin?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove the versionadded since we're unsure about the next release version

blockstart = blockstart + (space * bs)
bs_space = bs - 1 if endpoint else bs
blockstop = blockstart + (bs_space * step)
task = (partial(np.linspace, endpoint=endpoint, dtype=dtype), blockstart, blockstop, bs)
Copy link
Member

Choose a reason for hiding this comment

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

Might need to wrap this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @jakirkham, can do

bs_space = bs - 1 if endpoint else bs
blockstop = blockstart + (bs_space * step)
task = (partial(np.linspace, endpoint=endpoint, dtype=dtype), blockstart, blockstop, bs)
blockstart = blockstart + (step * bs)
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed for something?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed to update the start parameter for np.linspace that's being applied to each block

@jakirkham
Copy link
Member

Looks pretty good. Thanks @jrbourbeau. Couple minor comments above.

@jakirkham
Copy link
Member

LGTM. Will merge tomorrow end-of-day if no comments.

@jakirkham jakirkham merged commit 75eba00 into dask:master Jun 30, 2018
@jakirkham
Copy link
Member

Thanks @jrbourbeau :)

convexset added a commit to convexset/dask that referenced this pull request Jul 1, 2018
….com/convexset/dask into fix-tsqr-case-chunk-with-zero-height

* 'fix-tsqr-case-chunk-with-zero-height' of https://github.com/convexset/dask:
  fixed typo in documentation and improved clarity
  Implement .blocks accessor (dask#3689)
  Fix wrong names (dask#3695)
  Adds endpoint and retstep support for linspace (dask#3675)
  Add the @ operator to the delayed objects (dask#3691)
  Align auto chunks to provided chunks, rather than shape (dask#3679)
  Adds quotes to source pip install (dask#3678)
  Prefer end-tasks with low numbers of dependencies when ordering (dask#3588)
  Reimplement argtopk to release the GIL (dask#3610)
  Note `da.pad` can be used with `map_overlap` (dask#3672)
  Allow tasks back onto ordering stack if they have one dependency (dask#3652)
  Fix extra progressbar (dask#3669)
  Break apart uneven array-of-int slicing to separate chunks (dask#3648)
  fix for `dask.array.linalg.tsqr` fails tests (intermittently) with arrays of uncertain dimensions (dask#3662)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants