Skip to content

Commit 0a05f72

Browse files
authored
update dependencies to support Julia 1.12 in Huginn (#148)
1 parent f5d100c commit 0a05f72

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

Project.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Sleipnir"
22
uuid = "f5e6c550-199f-11ee-3608-394420200519"
33
authors = ["Jordi Bolibar <jordi.bolibar@gmail.com>", "Facundo Sapienza <fsapienza@berkeley.edu>", "Alban Gossard <alban.paul.gossard@gmail.com>", "Mathieu Le Séac'h"]
4-
version = "0.11.0"
4+
version = "0.11.1"
55

66
[deps]
77
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
@@ -38,12 +38,13 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3838
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
3939
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4040
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
41+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
4142

4243
[compat]
4344
BenchmarkTools = "1"
4445
CFTime = "0.2.1"
4546
CSV = "0.10.15"
46-
CairoMakie = "0.12.18, 0.13"
47+
CairoMakie = "0.15"
4748
CodecZlib = "0.7.6"
4849
ComponentArrays = "0.15"
4950
Contour = "0.6"
@@ -58,17 +59,18 @@ HDF5 = "0.17"
5859
ImageCore = "0.10"
5960
ImageInTerminal = "0.5"
6061
Infiltrator = "1.8"
61-
JET = "0.9.18"
62+
JET = "0.9, 0.10"
6263
JLD2 = "0.4, 0.5, 0.6"
63-
JSON = "0.21.4"
64+
JSON = "0.21.4, 1"
6465
MLStyle = "0.4"
65-
NCDatasets = "0.14.6"
66+
NCDatasets = "0.14"
6667
Observables = "0.5"
6768
Rasters = "0.13.0, 0.14"
6869
Revise = "3"
6970
Statistics = "1"
70-
Tar = "1.10.0, 1"
71+
Tar = "1"
7172
Unitful = "1"
73+
Zygote = "0.7"
7274
julia = "1.10"
7375

7476
[extras]

src/Sleipnir.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ using Printf
3434
using CFTime
3535
using MLStyle
3636
using FFTW
37+
using Zygote # To skip some lines in Sleipnir/src/simulations/results/results_utils.jl that causes an error with SciMLSensitivity
3738

3839
##############################################
3940
############ PARAMETERS ###############

src/models/Model.jl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ abstract type AbstractModel end
1111
const AbstractEmptyModel = Union{AbstractModel,Nothing}
1212

1313
"""
14+
Model{IFM <: AbstractEmptyModel, MBM <: AbstractEmptyModel, MLM <: AbstractEmptyModel}
15+
1416
A mutable struct that represents a model with three components: iceflow, mass balance, and machine learning.
1517
16-
Model{IFM <: AbstractEmptyModel, MBM <: AbstractEmptyModel, MLM <: AbstractEmptyModel}
18+
Model(
19+
iceflow::IFM,
20+
mass_balance::MBM,
21+
machine_learning::MLM,
22+
) where {IFM <: AbstractEmptyModel, MBM <: AbstractEmptyModel, MLM <: AbstractEmptyModel}
23+
24+
Model(;iceflow, mass_balance) = Model(iceflow, mass_balance, nothing)
25+
26+
Initialize Model (no machine learning model).
1727
1828
# Keyword arguments
1929
- `iceflow::IFM}`: Represents the iceflow component, which is an instance of `IFM`.
@@ -29,8 +39,16 @@ mutable struct Model{IFM <: AbstractEmptyModel, MBM <: AbstractEmptyModel, MLM <
2939
iceflow::IFM
3040
mass_balance::MBM
3141
machine_learning::MLM
32-
end
3342

43+
function Model(
44+
iceflow::IFM,
45+
mass_balance::MBM,
46+
machine_learning::MLM,
47+
) where {IFM <: AbstractEmptyModel, MBM <: AbstractEmptyModel, MLM <: AbstractEmptyModel}
48+
new{typeof(iceflow), typeof(mass_balance), typeof(machine_learning)}(
49+
iceflow, mass_balance, machine_learning)
50+
end
51+
end
3452
Model(;iceflow, mass_balance) = Model(iceflow, mass_balance, nothing)
3553

3654
"""

src/simulations/results/results_plotting_utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ end
221221
timeIdx::Union{Nothing,Int64} = nothing,
222222
figsize::Union{Nothing, Tuple{Int64, Int64}} = nothing,
223223
lengthscale::Float64 = 0.00001,
224-
arrowsize::Float64 = 0.5,
224+
tiplength::Float64 = 0.5,
225225
) -> Figure
226226
227227
Plot quivers for glacier variables.
@@ -235,7 +235,7 @@ Plot quivers for glacier variables.
235235
which selects the last element available.
236236
- `figsize::Union{Nothing, Tuple{Int64, Int64}}`: Size of the figure.
237237
- `lengthscale::Float64`: Lengthscale of the arrows in the quiver plot.
238-
- `arrowsize::Float64`: Arrow size in the quiver plot.
238+
- `tiplength::Float64`: Length of the arrow in the quiver plot.
239239
240240
# Returns
241241
- A plot of the glacier quivers.
@@ -247,7 +247,7 @@ function plot_glacier_quivers(
247247
timeIdx::Union{Nothing,Int64} = nothing,
248248
figsize::Union{Nothing, Tuple{Int64, Int64}} = nothing,
249249
lengthscale::Float64 = 0.00001,
250-
arrowsize::Float64 = 0.5,
250+
tiplength::Float64 = 0.5,
251251
)
252252
figKwargs = isnothing(figsize) ? Dict{Symbol,Any}() : Dict{Symbol,Any}(:size => figsize)
253253

@@ -304,7 +304,7 @@ function plot_glacier_quivers(
304304

305305
positions = Point2f.(reshape(X,:), reshape(Y,:))
306306
directions = Vec2f.(dataVx, -dataVy)
307-
arrows!(ax, positions, directions; arrowsize=arrowsize, lengthscale=lengthscale)
307+
arrows2d!(ax, positions, directions; tiplength=tiplength, lengthscale=lengthscale)
308308

309309
ax.title = "$title"
310310
ax.xlabel = "Longitude"

src/simulations/results/results_utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function create_results(
5959
end
6060
ϵ = 1e-6 # Need this because of numerical rounding
6161
compfct(t,val) = (t<=val+ϵ) & (t>=val-ϵ)
62-
solStepIndices = [findlast(t->compfct(t,val), solution.t) for val in timeSteps]
63-
ts = solution.t[solStepIndices]
62+
solStepIndices = Zygote.@ignore_derivatives [findlast(t->compfct(t,val), solution.t) for val in timeSteps] # selectTimeIdx(solution, timeSteps)
63+
ts = Zygote.@ignore_derivatives solution.t[solStepIndices]
6464
us = solution.u[solStepIndices]
6565
else
6666
ts = tstops

test/plot_utils.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ function glaciers2D_plots()
2020
results = Results(
2121
glaciers[1],
2222
ifm;
23-
H = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))]
23+
H = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))],
24+
Vx = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))],
25+
Vy = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))],
26+
Vx_ref = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))],
27+
Vy_ref = [abs.(randn(size(glaciers[1].H₀)...)),abs.(randn(size(glaciers[1].H₀)...))],
2428
)
2529

2630
# Test execution

0 commit comments

Comments
 (0)