Skip to content

Dask doc review: [2] Arrays #1592

Closed
Closed

Description

@pitrou

Array Overview

This should mention that Dask arrays are immutable. I only learnt about
it thanks to the Array.copy() docstring, which is probably suboptimal.

Store Dask Arrays

In this section, it is not mentioned how on-disk storage might interact
with distributed execution. Is the file saved in a local filesystem on
all nodes? Is the storage chunked? Does the user have to use a distributed
filesystem on their own?

As a side note, the "Other On-Disk Storage" and "On-Disk Storage" subsections
look a bit redundant with each other (especially the explanation of dask
working well with objects supporting the slice-to-get-a-numpy-array
convention).

Dask Array API

This page is quite a mouthful, I think it would benefit from splitting
up and/or a better ordering (perhaps keep the summary tables on a single
page?).

In documentation order, the API page should probably come after
the "Slicing", "Stack and Concatenate" and "Overlapping Blocks with
Ghost Cells" pages.

The detailed function list starts with "Other functions" which feels
a bit weird (and is really a hodge-podge of diverse functionality).

Some example blocks seem copied straight from the Numpy docs, without
any change to use the Dask APIs (for example the dask.array.all
example uses np.all, not da.all).

Some functions (e.g. da.angle, da.arccos, etc.) mention
returning an ndarray rather than a Dask array, I'm assuming this
is a mistake (perhaps not for reductions)?

Functions with an optional out argument often mention it has to
be an ndarray, can a Dask array be passed instead?

I'm wondering if copying the details of some Numpy docs (such as
semantic details of arccos) is useful, rather than simply linking
to those docs (Intersphinx helps there :-))? Perhaps Numpy compatibility
functions should be listed much more tersely (and in a dedicated section),
only insisting on Dask specifics?

Functions without a documentation
'''''''''''''''''''''''''''''''''

Those functions are listed but not documented: dask.array.modf,
dask.array.moment, dask.array.nanargmax,
dask.array.nanargmin, dask.array.ghost.map_overlap.

dask.array.from_delayed
'''''''''''''''''''''''

The doc doesn't state how to construct an array consisting of multiple
delayed chunks (perhaps by using dask.delayed.compute and then
concatenate?).

Is documented twice.

dask.array.topk
'''''''''''''''

"Runs in near linear time": I'm assuming this is conditioned on k being
small enough (is it running a variant of quickselect?). Otherwise,
with k == len(x) you would have a linear time distributed sort.

Is documented twice in the page.

dark.array.coarsen
''''''''''''''''''

"Coarsen array by applying reduction to fixed size neighborhoods":
not doc-related, but passing a neighborhood block size would feel
perhaps more intuitive than a dictionary of "coarsening factors".
Also what happens if some axis isn't in the dictionary?

The formatting for the trim_excess example is defective.

coarsen() is documented a second time, further in the document.

dask.array.all
''''''''''''''

"Axis or axes along which a logical AND reduction is performed.
The default (axis = None) is perform a logical OR over all the
dimensions of the input array.": are you sure the latter shouldn't
be "a logical AND"?

The out argument is documented but omitted from the function signature.
It is not mentioned whether out can be a Dask array or must be a
Numpy array.

"See doc.ufuncs (Section “Output arguments”) for more details.":
what is "doc.ufuncs"? (formatting glitch perhaps?)

The split_every argument in the signature is not documented.

The examples all mention np.all and not da.all.

dask.array.arange
'''''''''''''''''

linspace should be hyperlinked.

dask.array.array
''''''''''''''''

The subok doc mentions subclassing, is subclassing dask.array.array
actually supported?

dask.array.choose
'''''''''''''''''

The doc mentions mode and out arguments but they are not in the
function signature.

dask.array.compress
'''''''''''''''''''

The doc mentions an out argument that's not in the function signature.

dask.array.concatenate
''''''''''''''''''''''

Is documented twice.

dask.array.diag
'''''''''''''''

"whether it returns a copy or a view depends on what version of numpy you
are using.": does this apply to dask as well?

dask.array.empty, dask.array.ones, dask.array.zeros
'''''''''''''''''''''''''''''''''''''''''''''''''''

The function signature is misleadingly empty.

dask.array.fromfunction
'''''''''''''''''''''''

The argument called func in the signature is called function
in the documentation.

It is not stated what the function should return (presumably a Dask
or Numpy array... but perhaps also a delayed object?).

The chunks argument is not documented.

"Keywords other than dtype are passed to function.": I'm assuming you mean
other than dtype, chunks, func and shape?

dask.array.isnull, dask.array.notnull
'''''''''''''''''''''''''''''''''''''

The documentation is very succinct (assumes some knowledge of Pandas,
and lacks hyperlinking :-)).

dask.array.max (and other reductions)
'''''''''''''''''''''''''''''''''''''

The split_every argument is not documented.

dask.array.ravel
''''''''''''''''

The function signature doesn't mention the order argument.

dask.array.sqrt
'''''''''''''''

Mentions lib.scimath.sqrt which is not hyperlinked and doesn't
appear to be a Dask function (or is it?).

dask.array.stack
''''''''''''''''

Is documented twice.

dask.array.take
'''''''''''''''

The documentation mentions some arguments, out and mode, which are
not in the function signature.

dask.array.ghost.ghost
''''''''''''''''''''''

"The axes dict informs how many cells to overlap between neighboring blocks":
there doesn't seem to be an axis dict. Is this talking about the depth dict?

"The boundary condition on each axis. Options are ‘reflect’, ‘periodic’,
‘nearest’, ‘none’, an integer will fill the boundary with that integer.":
I may be misunderstanding, but is it limited to integer values? If I have
a float64 array, can't I pass a float64 value to fill the boundary with that
value?

dask.array.from_array
'''''''''''''''''''''

Is documented twice.

dask.array.store
''''''''''''''''

Is documented twice.

dask.array.to_npy_stack
'''''''''''''''''''''''

The bash example line is misformatted.

dask.array.random.product
'''''''''''''''''''''''''

This looks like itertools.product, is it a mistake that this is
documented as a member of dask.array.random?

dask.array.core functions
'''''''''''''''''''''''''

Are those really exported as members of dask.array.core rather than
dask.array?

Array.copy
''''''''''

"Copy array. This is a no-op for dask.arrays, which are immutable":

Array.cache
'''''''''''

The dict cache example shows a nice set of cache keys, but I can't reproduce
(instead of ('x', 0) and so on I would get
('add-cb8b158eb7e277df0a5dbd1d4b20c119', 0), etc.). I understand why,
but the example led me to think that perhaps Dask was playing nasty frame
inspection tricks to try and deduce the name of the local variable the
array was bound to :-)

Array.to_delayed
''''''''''''''''

"Convert Array into dask Values": wouldn't it be clearer to say "into dask
delayed objects"?

Array attributes
''''''''''''''''

Some Dask array attributes such as npartitions, chunks or shape
are not documented.

Overlapping Blocks with Ghost Cells

Trim Excess
'''''''''''

The example looks strange as it shows trim_internal returning a chunks
tuple -- I would expect it to return a new Dask array.

"at the moment trim cuts indiscriminately from the boundaries as well.
If you don’t specify a boundary kind then this may not be desired.":

I don't understand this comment at all. If I'm calling trim_internal
I'm probably expecting it to... trim. What does "indiscriminately" allude
to here?

Array Internal Design

This mentions a Dask array being composed of "dasks". However, at this
point in the documentation, a "dask" has not been defined (and the notion
of a dask graph hasn't been exposed yet). Perhaps some hyperlinking to
the relevant page would help.

It would be nice to show how all this can be queried on the array object
(the name, chunks and dask attributes, I suppose).

Keys of the Dask Graph
''''''''''''''''''''''

When reading at the example I wonder how each function knows whether a
tuple is an actual tuple argument or an indirect reference to another
node in the dask graph. It seems the actual representation would have
to be a bit more sophisticated.

Example -- eye function
'''''''''''''''''''''''''''

In this example, I wonder why dtype is passed to the Array
constructor rather than to the np.eye and np.zeros functions
in the dask graph. Does it add a conversion-copy step to the dask graph?

Example Dask Array

The page title is a bit misleading. I would expect it to explain how
to subclass and/or add functionality to Dask arrays. Instead it's a
followup to the "Internal Design" page, reusing the exact same
eye function example.

I am curious about the functions that can appear in a dask graph.
Do they have to be toplevel functions as in the examples (np.eye,
np.zeros, etc.) -- perhaps because they may be pickled to other
workers? Or can I pass any closure or nested function? The eye
and diag examples would perhaps be clearer with a closure --
especially if one wants to support the full signature of np.eye.

In the diag example, is it worth adding an input validation line
e.g. assert v.ndim == 1? That would document the expectation.

The tokens thing doesn't work here::

>>> dask.__version__
'0.11.0'
>>> from dask.array.core import tokens
Traceback (most recent call last):
  File "<ipython-input-44-385968ae7d58>", line 1, in <module>
    from dask.array.core import tokens
ImportError: cannot import name 'tokens'

Activity

  1. added a commit that references this issue on Oct 3, 2016
  2. mrocklin commented on Oct 3, 2016

    @mrocklin
    Member

    These comments are great. Thank you for spending the time here and I apologize for the delay in response. Some issues are handled in #1606, which answers some questions raised here. I'll answer some others below:

    Many of the errors listed here are because we are lazily just copying numpy docstrings using functools.wraps rather than properly writing down docstrings ourselves. This can lead to confusion. We should change this, but it requires substantial time.

    The use of the term "dasks" or "a dask" is no longer preferred. In the context where it is coming up here we replace it with "dask graph" or often "task graph". People were using this term to mean anything from a graph, to an array or dataframe, to even the distributed cluster of machines, for example "I set up a dask to compute my dasks". Now we try to avoid this term entirely.

    Array.copy
    "Copy array. This is a no-op for dask.arrays, which are immutable":

    Is this a suggestion to use a single-line docstring?

    When reading at the example I wonder how each function knows whether a
    tuple is an actual tuple argument or an indirect reference to another
    node in the dask graph

    This is a bit messy. It checks if the tuple is a member of the dictionary. If yes then it's a key, if not then its a literal. :/ This messiness requires that users are careful with their key names.

    @pitrou do you have any desire to implement some of these changes or would you prefer to work on other things?

  3. pitrou commented on Oct 5, 2016

    @pitrou
    MemberAuthor

    @pitrou do you have any desire to implement some of these changes or would you prefer to work on other things?

    Which ones exactly? Since you have started working on them, perhaps we should synchronize ourselves.

  4. mrocklin commented on Oct 5, 2016

    @mrocklin
    Member

    Yeah, I wrote that comment before deciding to handle some of the comments. There is still a decent amount of work to do, mostly around writing our own docstrings. This isn't necessarily the best use of your time though. Personally I am more interested in focusing your attention on the distributed scheduler.

  5. pitrou commented on Oct 5, 2016

    @pitrou
    MemberAuthor

    Le 05/10/2016 à 16:12, Matthew Rocklin a écrit :

    Personally I am more interested in focusing your attention
    on the distributed scheduler.

    Would you have some specific issue to suggest?

  6. added a commit that references this issue on Oct 5, 2016
  7. added this to the 0.11.1 milestone on Oct 11, 2016
  8. removed this from the 0.11.1 milestone on Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions