Skip to content

map_blocks with dtype induce dummy function call (Doc say it shouldn't) #6690

@oarcher

Description

@oarcher

dask.array.map_blocks says about dtype:

The dtype of the output array. It is recommended to provide this. If not provided, will be inferred by applying the function to a small set of fake data.

So if dtype is provided, the function should not be called.

This minimal example will print a message if the function is called:

import dask.array as da


def block_func(block,block_info=None):
    if block_info is None:
        print("block_func called with block_info=None")
    return block + 0.5

data=da.arange(10,chunks=2)
data.map_blocks(block_func, dtype='f8')

This code print "block_func called with block_info=None", and that show that the function is called, despite of the documentation.

I've found that using the undocumented keyword meta=True, it's work as expected, and the function is not called:

data.map_blocks(block_func, dtype='f8',meta=True)

Is it a documentation problem, or am I missing something else ?

Environment:

  • Dask version: 2.28.0
  • Python version: 3.8.2
  • Operating System: linux
  • Install method (conda, pip, source): pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions