Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pairs of DimVector do not reflect lookup values #784

Closed
asinghvi17 opened this issue Aug 26, 2024 · 5 comments
Closed

pairs of DimVector do not reflect lookup values #784

asinghvi17 opened this issue Aug 26, 2024 · 5 comments

Comments

@asinghvi17
Copy link
Collaborator

Not sure if this should happen or not, but see the following MWE:

julia> DimVector(rand(10), (X(16:25),)) |> pairs
pairs(::DimVector{Float64, Tuple{X{DimensionalData.Dimensions.Lookups.Sampled{Int64, UnitRange{Int64}, DimensionalData.Dimensions.Lookups.ForwardOrdered, DimensionalData.Dimensions.Lookups.Regular{Int64}, DimensionalData.Dimensions.Lookups.Points, DimensionalData.Dimensions.Lookups.NoMetadata}}}, Tuple{}, Vector{Float64}, DimensionalData.NoName, DimensionalData.Dimensions.Lookups.NoMetadata})(...):
  1  => 0.151612
  2  => 0.400987
  3  => 0.928486
  4  => 0.245337
  5  => 0.747621
  6  => 0.327087
  7  => 0.781531
  8  => 0.0161408
  9  => 0.930245
  10 => 0.656637

I would naively expect that the LHS values on the pairs would be from 16 to 25 (that's what OffsetArrays does).

@asinghvi17
Copy link
Collaborator Author

I guess that indexing the dimvector works with one based indexing, so there is a good reason to have the pairs work the way they are. Feel free to close this issue then :D (though at least it's searchable now)

@felixcremer
Copy link
Contributor

If you want the dimensions in there you can have a look at DimIndices.

This would give you the keys with the Dimension information.

Repository owner deleted a comment Aug 26, 2024
@rafaqz
Copy link
Owner

rafaqz commented Aug 26, 2024

I don't think much thought went into it honestly

@rafaqz
Copy link
Owner

rafaqz commented Aug 26, 2024

We can wrap it with At for 16:25 to work as indices, so it could be:

  At(16)  => 0.151612
  At(17)  => 0.400987
  3  => 0.928486
...
  At(25) => 0.656637

But it seems kinda weird, and close to what DimSelectors gives you but less useful.

@asinghvi17
Copy link
Collaborator Author

Yeah, as long as direct indexing with (idx, val) in pairs(dimarray) works (which it looks like it does) then it's probably fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants