Skip to content

Commit f03d827

Browse files
committed
Fix for Julia 1.10
1 parent 3652db4 commit f03d827

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/quirks.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ hasqns(a::AbstractITensor) = all(hasqns, inds(a))
2020
# TODO: Investigate this and see if we can get rid of it.
2121
Base.Broadcast.extrude(a::AbstractITensor) = a
2222

23+
# See: https://github.com/JuliaLang/julia/blob/v1.11.4/base/namedtuple.jl#L269
24+
# `filter(f, ::NamedTuple)` is available in Julia v1.11, delete once
25+
# we drop support for Julia v1.10.
26+
filter_namedtuple(f, xs::NamedTuple) = xs[filter(k -> f(xs[k]), keys(xs))]
27+
2328
function translate_factorize_kwargs(;
2429
# MatrixAlgebraKit.jl/TensorAlgebra.jl kwargs.
2530
orth=nothing,
@@ -35,7 +40,7 @@ function translate_factorize_kwargs(;
3540
rtol = @something rtol cutoff Some(nothing)
3641
maxrank = @something maxrank maxdim Some(nothing)
3742
!isnothing(maxrank) && error("`maxrank` not supported yet.")
38-
return filter(!isnothing, (; orth, rtol, maxrank, kwargs...))
43+
return filter_namedtuple(!isnothing, (; orth, rtol, maxrank, kwargs...))
3944
end
4045

4146
using TensorAlgebra: TensorAlgebra, factorize

0 commit comments

Comments
 (0)