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

Type piracy on CommonDataModel #219

Closed
rafaqz opened this issue Jul 25, 2023 · 5 comments
Closed

Type piracy on CommonDataModel #219

rafaqz opened this issue Jul 25, 2023 · 5 comments

Comments

@rafaqz
Copy link
Contributor

rafaqz commented Jul 25, 2023

This line is type piracy on CommonDataModel.jl:

Base.view(v::AbstractVariable,indices::Union{Int,Colon,AbstractVector{Int}}...) = SubVariable(v,indices...)

Which causes test failures here: https://github.com/rafaqz/Rasters.jl/actions/runs/5475178088/job/14825206026?pr=416#step:5:802

@tcarion FYI

Should it instead dispatch on SubVariable ?

@Alexander-Barth
Copy link
Owner

From you comment:

#221 (comment)

Yes, indeed, it would be better to move SubVariable related view function to CommonDataModel.jl.

@rafaqz
Copy link
Contributor Author

rafaqz commented Jul 30, 2023

That means the SubVaroable also needs to move to CommonDataModel...

That may be unnnecessary as DiskArrays already handles views pretty well.

If you dont want to use that, we could instead use a Union of all the netcdf variable types rather than AbstractVariable... I'll change the PR to that as a short term fix for now.

@rafaqz
Copy link
Contributor Author

rafaqz commented Jul 30, 2023

Loking at it this is a bit of a design problem that CommonDataModel depends on NCDatasets.SubVariable for handling view on all AbstractVariable.

Do you want to instead use DiskArrays.jl SubDiskArray or SubVariable in CommonDataModel.jl ? Even if we move SubVariable to CommonDataModel.jl it will cause dispatch issues with SubDiskArray and the PRs to add DiskArrays support.

We need to make a pretty high level design choice here: DiskArrays.jl or no DiskArrays.jl

@tcarion
Copy link
Contributor

tcarion commented Aug 4, 2023

I actually encountered an issue with the view method after making Variable implement DiskArray, see this commit. So this should be fixed when #205 is merged.

@Alexander-Barth
Copy link
Owner

#205 is merged and the type piracy does no longer exists as SubVariable has been moved to CommonDataModel.

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

Successfully merging a pull request may close this issue.

3 participants