JuliaGeometry / JuliaGeometry/GeometryBasics.jl

Do not define `Base.in` instead of `Base.issubset` (taking set theory seriously)

Open
#110 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
215
Forks
64
Avg merge
3d 18h
Merged PRs (30d)
2

Description

The definition at

https://github.com/JuliaGeometry/GeometryBasics.jl/blob/234699e015ccb23bdaab26539dfc8fdfa9ff6add/src/primitives/rectangles.jl#L469-L481

is not in the spirit of Base.in, and instead that procedure should be a method for Base.issubset ().

see for example:

https://github.com/invenia/Intervals.jl/blob/168565ef0a40d022bfe4030d0178cb1b83fff6cb/src/interval.jl#L370-L375

Base.in(a, b::AbstractInterval) = !(a ≫ b || a ≪ b)

function Base.in(a::AbstractInterval, b::AbstractInterval)
    # Intervals should be compared with set operations
    throw(ArgumentError("Intervals can not be compared with `in`. Use `issubset` instead."))
end

These operations are related, even graphically (∈ ⊂), but should not be mixed up.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/primitives/rectangles.jl lines 469-481 and compare the current Base.in definition with the referenced Intervals.jl implementation. Check Julia's Base.issubset and Base.in conventions, then update the rectangle operation so set containment uses issubset rather than in. Done means the API follows the issue's set-theoretic distinction and the existing behavior is covered by the relevant project tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.