JuliaData / JuliaData/SentinelArrays.jl
Surprising behaviors in array initialization
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 22
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
The documentation says:
For isbits types, a random/reasonable sentinel will be attempted if none provided.
...
ForIntegertypes, all bit patterns are valid, so a random value is chosen;
But the constructor uses a constant default value. For example the default sentinel for Int is -1, so SentinelArray([-1, -1, -1]) creates an array with three missing values. From the documentation I expected an array of three -1, and a random sentinel different from -1.
The behavior with undef is also surprising: The documentation refers to the "standard undef pattern". As I understand, undef is meant to create uninitialized arrays, for cases where initialization is useless and undesired for performance reasons. But SentinelVector{Int}(undef, 3) actually initializes the array with 3 missing values. I would suggest removing the undef argument from the constructors (so a vector full of 3 missing values can be created with SentinelVector{Int}(3)). A later version could re-introduce the undef pattern with the correct semantics...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the documented sentinel behavior with the SentinelArray and SentinelVector constructors, especially the default sentinel and the undef argument. Check how SentinelArray([-1, -1, -1]) and SentinelVector{Int}(undef, 3) behave. Done means the constructor semantics and documentation agree, including the intended handling of missing values and uninitialized arrays.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100