Skip to content

Commit d779f74

Browse files
authored
Switch to extensions instead of requires for datasets (#24)
* Switch to extensions instead of requires for datasets * Move all array interface implementations to extensions This moves everything from using Requires to the new extensions setup. * Switch the array tests to testitems This ensures, that the tests for different backends are independent. * Remove the Requires setup for lower julia versions We decided to only support julia versions larger than 1.9 * Switch CI to test on julia 1.9 instead of 1.6 When we restrict the Julia version to 1.9 we should also stop testing on 1.6 * Remove Zarr and NetCDF as dependencies * Remove AxisIndices This seems to be not maintained anymore with the last commit three years ago * Stop tracking Manifest.toml * Remove AxisIndices also from test environment * Add testing on nightly * Bump version to 0.7.0
1 parent c9d7d6d commit d779f74

20 files changed

+1061
-230
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.6'
16+
- '1.9'
1717
- '1'
18+
- 'nightly'
1819
os:
1920
- ubuntu-latest
2021
- macOS-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.jl.mem
44
/deps/deps.jl
55
/docs/build
6+
Manifest.toml

Manifest.toml

Lines changed: 0 additions & 105 deletions
This file was deleted.

Project.toml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
name = "YAXArrayBase"
22
uuid = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
33
authors = ["Fabian Gans <[email protected]>"]
4-
version = "0.6.1"
4+
version = "0.7.0"
55

66
[deps]
77
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
88
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
99
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
10-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
10+
1111

1212
[compat]
13-
DataStructures = "0.17, 0.18"
14-
Requires = "1"
15-
julia = "1.6"
13+
DataStructures = "0.17,0.18"
14+
julia = "1.9"
15+
ArchGDAL = "0.10"
16+
AxisArrays = "0.4"
17+
AxisKeys = "0.2"
18+
DimensionalData = "0.24"
19+
NetCDF = "0.11"
20+
Zarr = "0.8"
21+
22+
[extensions]
23+
ArchGDALExt = "ArchGDAL"
24+
AxisArraysExt = "AxisArrays"
25+
AxisKeysExt = "AxisKeys"
26+
DimensionalDataExt = "DimensionalData"
27+
NamedDimsExt = "NamedDims"
28+
NetCDFExt = "NetCDF"
29+
ZarrExt = "Zarr"
1630

31+
[weakdeps]
32+
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
33+
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
34+
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
35+
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
36+
NamedDims = "356022a1-0364-5f58-8944-0da4b18d706f"
37+
NetCDF = "30363a11-5582-574a-97bb-aa9a979735b9"
38+
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"

src/axisarrays/archgdal.jl renamed to ext/ArchGDALExt/ArchGDALExt.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import .ArchGDAL: RasterDataset, AbstractRasterBand,
1+
module ArchGDALExt
2+
import ArchGDAL: RasterDataset, AbstractRasterBand,
23
getgeotransform, width, height, getname, getcolorinterp,
34
getband, nraster, getdataset
5+
using ArchGDAL: ArchGDAL as AG
6+
import YAXArrayBase: dimname, dimnames, dimvals, iscontdim, getattributes, getdata, yaxcreate
7+
8+
#include("archgdaldataset.jl")
49

510
function dimname(a::RasterDataset, i)
611
if i == 1
@@ -33,10 +38,10 @@ end
3338
iscontdim(a::RasterDataset, i) = i < 3 ? true : nraster(a)<8
3439
function getattributes(a::RasterDataset)
3540
globatts = Dict{String,Any}(
36-
"projection_PROJ4"=>ArchGDAL.toPROJ4(ArchGDAL.newspatialref(ArchGDAL.getproj(a))),
37-
"projection_WKT"=>ArchGDAL.toWKT(ArchGDAL.newspatialref(ArchGDAL.getproj(a))),
41+
"projection_PROJ4"=>AG.toPROJ4(AG.newspatialref(AG.getproj(a))),
42+
"projection_WKT"=>AG.toWKT(AG.newspatialref(AG.getproj(a))),
3843
)
39-
bands = (getbandattributes(ArchGDAL.getband(a, i)) for i in 1:size(a, 3))
44+
bands = (getbandattributes(AG.getband(a, i)) for i in 1:size(a, 3))
4045
allbands = mergewith(bands...) do a1,a2
4146
isequal(a1,a2) ? a1 : missing
4247
end
@@ -65,7 +70,7 @@ function dimvals(b::AbstractRasterBand, i)
6570
end
6671
iscontdim(a::AbstractRasterBand, i) = true
6772
function getattributes(a::AbstractRasterBand)
68-
atts = getattributes(ArchGDAL.RasterDataset(ArchGDAL.getdataset(a)))
73+
atts = getattributes(AG.RasterDataset(AG.getdataset(a)))
6974
bandatts = getbandattributes(a)
7075
merge(atts, bandatts)
7176
end
@@ -84,4 +89,5 @@ function getbandattributes(a::AbstractRasterBand)
8489
insertattifnot!(atts, AG.getoffset(a), "add_offset", iszero)
8590
insertattifnot!(atts, AG.getscale(a), "scale_factor", x->isequal(x, one(x)))
8691
atts
92+
end
8793
end

src/datasets/archgdal.jl renamed to ext/ArchGDALExt/archgdaldataset.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import .ArchGDAL: RasterDataset, AbstractRasterBand,
2-
getgeotransform, width, height, getname, getcolorinterp,
3-
getband, nraster, getdataset, ArchGDAL
4-
using .ArchGDAL.DiskArrays: GridChunks, DiskArrays, eachchunk
5-
const AG = ArchGDAL
6-
71
struct GDALBand{T} <: AG.DiskArrays.AbstractDiskArray{T,2}
82
filename::String
93
band::Int
@@ -221,8 +215,10 @@ allow_parallel_write(::GDALDataset) = false
221215
allow_missings(::Type{<:GDALDataset}) = false
222216
allow_missings(::GDALDataset) = false
223217

224-
backendlist[:gdal] = GDALDataset
225-
push!(backendregex,r".tif$"=>GDALDataset)
226-
push!(backendregex,r".gtif$"=>GDALDataset)
227-
push!(backendregex,r".tiff$"=>GDALDataset)
228-
push!(backendregex,r".gtiff$"=>GDALDataset)
218+
function __init__()
219+
backendlist[:gdal] = GDALDataset
220+
push!(backendregex,r".tif$"=>GDALDataset)
221+
push!(backendregex,r".gtif$"=>GDALDataset)
222+
push!(backendregex,r".tiff$"=>GDALDataset)
223+
push!(backendregex,r".gtiff$"=>GDALDataset)
224+
end

src/axisarrays/axisarrays.jl renamed to ext/AxisArraysExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using .AxisArrays: AxisArrays, AxisArray
2-
1+
module AxisArraysExt
2+
using AxisArrays: AxisArrays, AxisArray
3+
import YAXArrayBase: dimname, dimnames, dimvals, iscontdim, getattributes, getdata, yaxcreate
34
dimname(a::AxisArray, i) = AxisArrays.axisnames(a)[i]
45
dimnames(a::AxisArray) = AxisArrays.axisnames(a)
56
dimvals(a::AxisArray, i) = AxisArrays.axisvalues(a)[i]
@@ -11,3 +12,4 @@ function yaxcreate(::Type{<:AxisArray}, data, dnames, dvals, atts)
1112
end
1213
AxisArray(data; d...)
1314
end
15+
end
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import .AxisKeys
2-
1+
module AxisKeysExt
2+
import AxisKeys
3+
import YAXArrayBase: dimname, dimnames, dimvals, iscontdim, getattributes, getdata, yaxcreate
34
dimnames(a::AxisKeys.KeyedArray) = AxisKeys.dimnames(a)
45

56
dimvals(a::AxisKeys.KeyedArray,i) = AxisKeys.getproperty(a,AxisKeys.dimnames(a,i))
@@ -8,3 +9,4 @@ getdata(a::AxisKeys.KeyedArray) = parent(parent(a))
89

910
yaxcreate(::Type{<:AxisKeys.KeyedArray}, data, dnames, dvals, atts) =
1011
AxisKeys.KeyedArray(data; map(i->dnames[i]=>dvals[i],1:ndims(data))...)
12+
end

src/axisarrays/dimensionaldata.jl renamed to ext/DimensionalDataExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using .DimensionalData: DimArray, DimensionalData, data, Dim, metadata
2-
1+
module DimensionalDataExt
2+
using DimensionalData: DimArray, DimensionalData, data, Dim, metadata
3+
import YAXArrayBase: dimname, dimnames, dimvals, iscontdim, getattributes, getdata, yaxcreate
34
_dname(::DimensionalData.Dim{N}) where N = N
45
_dname(d::DimensionalData.Dimension) = DimensionalData.name(d)
56
dimname(x::DimArray, i) = _dname(DimensionalData.dims(x)[i])
@@ -17,3 +18,4 @@ function yaxcreate(::Type{<:DimArray},data,dnames,dvals,atts)
1718
end
1819
DimArray(data,d,metadata = atts)
1920
end
21+
end
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using .NamedDims: NamedDimsArray
1+
module NamedDimsExt
2+
using NamedDims: NamedDimsArray
3+
import YAXArrayBase: dimname, dimnames, dimvals, iscontdim, getattributes, getdata, yaxcreate
24
dimname(a::NamedDimsArray{N},i) where N = N[i]
35
dimnames(a::NamedDimsArray{N}) where N = N
46
getdata(a::NamedDimsArray) = parent(a)
57
function yaxcreate(::Type{<:NamedDimsArray},data, dnames, dvals, atts)
68
n = ntuple(i->dnames[i],ndims(data))
79
NamedDimsArray(data,n)
810
end
11+
end

0 commit comments

Comments
 (0)