Skip to content

API: lazy_xp_function: rename allow_dask_compute to max_dask_computes and adjust accepted values #415

Closed

Description

@ev-br

lazy_xp_function' accepts its allow_dask_compute argument as either bool or int where True is equivalent to a very large integer:

    allow_dask_compute : bool | int, optional
        Whether `func` is allowed to internally materialize the Dask graph, or maximum
        number of times it is allowed to do so. 

This is very much unexpected. First of all, bool | int typing is equivalent to just int. So I'd expect that either False is converted to zero, or an int gets converted to a boolean via bool(allow_dask_compute).

Since the "number of times" is non-negative, I'd very much expect to express "any number of times" as -1 or just negative.

Activity

  1. lucascolley commented on Sep 8, 2025

    @lucascolley
    Member
  2. crusaderky commented on Sep 8, 2025

    @crusaderky
    Contributor

    False (do not allow) and 0 (allow 0 times) are equivalent.

    I'm against -1 as a special value for inifinity, because it's lesser than 0 and it is not intuitive what it means.

    "allow=True" on the other hand is intuitive. It is allowed, full stop, do not trip on it no matter how high. "allow=False" is also intuitive: crash immediately no matter how small the infraction.

    allow_dask_compute=True is actually a second iteration of this design. The first iteration was allow_dask_compute=999, which a lot of people found confusing, so I added the option for bool.

    I'm against changing this. "bool | int" being a redundant alias for "int" is a design flaw of python typing which has already been extensively discussed elsewhere, and IMHO not worth arguing about here.

  3. lucascolley commented on Sep 8, 2025

    @lucascolley
    Member

    While I agree with the sentiment that a single type would be nicer than a (fake in this case...) union type, I'm still pretty happy with the current state, and don't feel that this is worth making a change.

  4. ev-br commented on Sep 8, 2025

    @ev-br
    MemberAuthor

    I'll just note that IMO this is the case where each individual step might make sense and is intuitive, but the final result does not and is not intuitive.

  5. steppi commented on Oct 18, 2025

    @steppi
    Contributor

    I suggest:

    • Renaming allow_dask_compute to max_dask_computes or something of similar meaning
    • Having max_dask_computes=0 yield the current behavior of allow_dask_compute=False
    • Using max_dask_computes=None for the current behavior of allow_dask_compute=True

    I think any lack of clarity goes away if the variable name matches the meaning of the values rather than suggesting a boolean when the values are counts. None gives a natural value to mean no limit on dask computes.

  6. lucascolley commented on Oct 18, 2025

    @lucascolley
    Member

    I suggest:

    • Renaming allow_dask_compute to max_dask_computes or something of similar meaning
    • Having max_dask_computes=0 yield the current behavior of allow_dask_compute=False
    • Using max_dask_computes=None for the current behavior of allow_dask_compute=True

    I think any lack of clarity goes away if the variable name matches the meaning of the values rather than suggesting a boolean when the values are counts. None gives a natural value to mean no limit on dask computes.

    thanks Albert, that looks nice to me!

  7. changed the title [-]`allow_dask_compute` argument of `lazy_xp_function` domain[/-] [+]API: lazy_xp_function: rename `allow_dask_compute` to `max_dask_computes` and adjust accepted values[/+] on Oct 18, 2025
  8. added this to the 0.10.0 milestone on Oct 18, 2025
  9. crusaderky commented on Oct 23, 2025

    @crusaderky
    Contributor

    I suggest:

    • Renaming allow_dask_compute to max_dask_computes or something of similar meaning
    • Having max_dask_computes=0 yield the current behavior of allow_dask_compute=False
    • Using max_dask_computes=None for the current behavior of allow_dask_compute=True

    I think any lack of clarity goes away if the variable name matches the meaning of the values rather than suggesting a boolean when the values are counts. None gives a natural value to mean no limit on dask computes.

    I'm happy with this.
    Now we just need to find someone who is irked enough by the current syntax to implement it (with deprecation system and scipy migration on top).

  10. removed this from the 0.10.0 milestone on Feb 23, 2026
  11. lucascolley commented on Feb 23, 2026

    @lucascolley
    Member

    I suggest:

    • Renaming allow_dask_compute to max_dask_computes or something of similar meaning
    • Having max_dask_computes=0 yield the current behavior of allow_dask_compute=False
    • Using max_dask_computes=None for the current behavior of allow_dask_compute=True

    I think any lack of clarity goes away if the variable name matches the meaning of the values rather than suggesting a boolean when the values are counts. None gives a natural value to mean no limit on dask computes.

    I'm happy with this. Now we just need to find someone who is irked enough by the current syntax to implement it (with deprecation system and scipy migration on top).

    do you fit the criteria @ev-br :) ?

  12. steppi commented on Feb 23, 2026

    @steppi
    Contributor

    @lucascolley. Following the decision in scipy/scipy#24205, my impression is that this has become moot for SciPy developers until Dask support is re-prioritized.

  13. added theissue type on May 9, 2026
  14. lucascolley commented on Aug 12, 2026

    @lucascolley
    Member

    going to transfer this to a discussion, makes sense to keep it discoverable in case Dask support is re-prioritised I suppose

  15. locked and limited conversation to collaborators on Aug 12, 2026
  16. converted this issue into a discussion #917 on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions