-
Notifications
You must be signed in to change notification settings - Fork 51
Include refdims as columns in DimTable #1119
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
base: main
Are you sure you want to change the base?
Conversation
end | ||
function DimTable(xs::Vararg{AbstractDimArray}; layernames=nothing, mergedims=nothing) | ||
function DimTable( | ||
xs::Vararg{AbstractDimArray}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear from the documentation what assumptions this method makes about xs
, so it's possible there's a mistake in this method.
|
||
end | ||
|
||
_dims(t::DimTable) = getfield(t, :dims) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it at all weird that dims(t::DimTable)
will return fewer dims than the actual dims included in the table (because it just forwards to the parent)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even know it did that. We can fix these things and merge to breaking instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't do that until this PR, since previously the table's dims were the parent dims, but now additional dims may be included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh you mean the refdims? Yeah hkw do we keep that separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 ways I can think of:
- Keep
dims(::DimTable)
forwarding to the parent and add the methodrefdims(t::DimTable) = otherdims(dims(t), _dims(t))
. Maybe not the right way to go if the parent is a slice of aDimMatrix
where both dimensions have the same dim, but that kind of thing in general may not be well supported. - Remove the
dims
field and add arefdims
andrefdimarrays
field. Thenrefdims(t::DimTable) = getfield(t, :refdims)
. I started implementing this version originally and abandoned it because it makes the column indexing more complicated, but I could bring it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not just do refdims(dt::DimTable) = refdims(parent(dt))
? Maybe I'm missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it depends on what dims(::DimTable)
and refdims(::DimTable)
should mean. With this PR, a user can provide arbitrary refdims
to the DimTable
, so they may not even be in the parent. But should refdims(::DimTable)
return those user-provided refdims
(currently only stored in (::DimTable).dims
) or return those of the parent? Should dims(::DimTable)
return just the dims of the parent, or should it return all dimensions corresponding to columns (with this PR, also includes user-provided refdims).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1119 +/- ##
==========================================
- Coverage 86.90% 86.89% -0.02%
==========================================
Files 55 55
Lines 5338 5341 +3
==========================================
+ Hits 4639 4641 +2
- Misses 699 700 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/tables.jl
Outdated
- `refdims`: Additional reference dimensions to add to the table, defaults to the reference | ||
dimensions of the input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer if this was a bool that determines whether or not refdims are included as columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, though the current approach would support only including a subset of refdims, which maybe is useful in some cases? What other methods implemented here produce refdims besides slicing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the current syntax with a tuple as it's the same as the constructor syntax, and its flexible.
But to merge this to main ()
would need to be the default.
We can then change that on breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sethaxen CF standards has its own refdims concept so Rasters.jl Raster can load with refdims already in place.
To make feature non-breaking
This PR adds a keyword
refdims
toDimTable
, defaulting tothe refdims of the inputan empty tuple. All refdims are included as table columns. Fixes #884Potentially breaking changes:
dims
field added toDimTable
refdims
columns included by defaultExample