Skip to content

Intersection doesn't give back correct result #61

Description

@Wikunia

In certain cases the intersect functionality doesn't work as expected. I couldn't break it down to a minimal example unfortunately but this is one case in which it fails.

Expected Behavior

The id 1024648 should be part of the set in intersection but isn't.

Steps to Reproduce (for bugs)

json_ranges = JSON3.read("ranges.json") # see below
new_ranges = Vector{Tuple{Float32, Float32}}()
for range in json_ranges
    push!(new_ranges, (range[1], range[2]))
end

function get_interval_map(ranges)
	interval_map = IntervalMap{Float32, Vector{Int}}()
	i = 0
	@inbounds for range in ranges
		i += 1
                # This part seems to be crucial so I think it has something to do with not handling NaN correctly
		if range[1] == -1
			range = (NaN, NaN)
		end
		if haskey(interval_map, range)
			vals = get(interval_map, range, Int[]).value
			push!(vals, i)
			interval_map[range] = vals
		else 
			interval_map[range] = [i]
		end
		if i == 1024648
			@show range
		end
	end
	return interval_map
end

interval_map = get_interval_map(new_ranges)

@show get(interval_map, (78.2874f0, 79.9925f0), Int[])

# IntervalValue{Float32, Vector{Int64}}
# (78.2874,79.9925) => [1024648, 1024649]

 infaces = Set{Int}()
for intersec in intersect(interval_map, (78.45005f0, 78.45005f0))
	union!(infaces, intersec.value)
end

@show 1024648 in infaces
# false => this should show true

ranges.json

Your Environment

  • Package Version used: 1.1.0
  • Julia Version used:1.10.4
  • Operating System and version (desktop or mobile): MacOS and Linux both fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions