Skip to content

Breaking behaviour change relating to using Boolean operations on faces #249

@Kevin-Mattheus-Moerman

Description

@Kevin-Mattheus-Moerman

@ffreyer I can use something like the below to find the indices of points part of a face not equal to some value (the indices of the other points, this is handy e.g. to find which points of a face do not touch a point of something else).

f = QuadFace{Int64}(1,2,3,4) # Some face
indicesOther = f[f.!=3] 

For my project, when my compat features GeometryBasics = "0.3, 0.4", the use of f[f.!=3] returns:

3-element Vector{Int64}:
 1
 2
 4

This is the desired/expected behaviour, i.e. I can use the boolean f.!=3 to grab the indices that are not 3.

However, when my compat features GeometryBasics = "0.5", the use of f[f.!=3] returns:

ERROR: ArgumentError: invalid index: true of type Bool
Stacktrace:
 [1] to_index(i::Bool)
   @ Base ./indices.jl:308
 [2] to_index(A::TriangleFace{Int64}, i::Bool)
   @ Base ./indices.jl:292
 [3] to_indices
   @ ./indices.jl:368 [inlined]
 [4] to_indices
   @ ./indices.jl:365 [inlined]
 [5] getindex
   @ ./abstractarray.jl:1312 [inlined]
 [6] (::GeometryBasics.var"#51#52"{TriangleFace{Int64}})(i::Bool)
   @ GeometryBasics ~/.julia/packages/GeometryBasics/79wKA/src/basic_types.jl:39
 [7] map
   @ ./tuple.jl:357 [inlined]
 [8] getindex(elements::TriangleFace{Int64}, face::TriangleFace{Bool})
   @ GeometryBasics ~/.julia/packages/GeometryBasics/79wKA/src/basic_types.jl:39
 [9] top-level scope
   @ REPL[7]:1

So this is braking behaviour of course. Is this something you will be able to address or do I need to alter my code?

Separately I should add that in both instances above (both for early versions and the latest version of GeometryBasics) I find this behaviour odd, i.e. that f.!=3 returns a face containing Bools, that is never a valid/useful thing I'd say. So perhaps this should return some kind of vector of Bool entries instead? I'd say making that change would solve the above too.

f.!=3

4-element QuadFace{Bool} with indices SOneTo(4):
 1
 1
 0
 1

Let me know if you need any more information.

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