JuliaApproximation / DomainSets.jl

A Julia package for describing domains as continuous sets of elements
MIT License
72 stars 12 forks source link

enable broadcast with notin #135

Closed daanhb closed 1 year ago

daanhb commented 1 year ago

We had the following asymmetric situation, where broadcast would work for in but not for :

julia> using DomainSets

julia> rand(2) .∈ (0..1)
2-element BitVector:
 1
 1

julia> rand(2) .∉ (0..1)
ERROR: MethodError: no method matching size(::ClosedInterval{Int64})

This PR adds broadcast functionality for the method. The result is equivalent to typing A .∉ Ref(0..1) instead.

Currently, domains participate in broadcast using DomainSetStyle as broadcaststyle. A few functions, like in and are now supported by intercepting them during broadcast. There might be a more generic way to do it, but I didn't see it. In any case, using domains in conjunction with broadcast is possible by using Ref(d). We may want to be conservative in allowing just d instead, and in and seem two valid special cases.

codecov[bot] commented 1 year ago

Codecov Report

Base: 85.71% // Head: 85.73% // Increases project coverage by +0.01% :tada:

Coverage data is based on head (927600a) compared to base (1dd3a2e). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #135 +/- ## ========================================== + Coverage 85.71% 85.73% +0.01% ========================================== Files 33 33 Lines 2633 2636 +3 ========================================== + Hits 2257 2260 +3 Misses 376 376 ``` | [Impacted Files](https://codecov.io/gh/JuliaApproximation/DomainSets.jl/pull/135?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation) | Coverage Δ | | |---|---|---| | [src/generic/broadcast.jl](https://codecov.io/gh/JuliaApproximation/DomainSets.jl/pull/135?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL2dlbmVyaWMvYnJvYWRjYXN0Lmps) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.