Skip to content

Commit 006584b

Browse files
committed
Add JET tests
1 parent aef7422 commit 006584b

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
2121
AliasTables = "1"
2222
DataAPI = "1"
2323
DataStructures = "0.10, 0.11, 0.12, 0.13, 0.14, 0.17, 0.18"
24+
JET = "0.9.18, 0.10"
2425
LinearAlgebra = "<0.0.1, 1"
2526
LogExpFunctions = "0.3"
2627
Missings = "0.3, 0.4, 1.0"
@@ -35,9 +36,10 @@ julia = "1.10"
3536
[extras]
3637
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
3738
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
39+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
3840
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3941
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
4042
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4143

4244
[targets]
43-
test = ["Dates", "DelimitedFiles", "OffsetArrays", "StableRNGs", "Test"]
45+
test = ["Dates", "DelimitedFiles", "JET", "OffsetArrays", "StableRNGs", "Test"]

src/cov.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ end
2323

2424
## scatter matrix
2525

26-
_unscaled_covzm(x::DenseMatrix, dims::Colon) = unscaled_covzm(x)
2726
_unscaled_covzm(x::DenseMatrix, dims::Integer) = unscaled_covzm(x, dims)
28-
29-
_unscaled_covzm(x::DenseMatrix, wv::AbstractWeights, dims::Colon) =
30-
_symmetrize!(unscaled_covzm(x, _scalevars(x, wv)))
3127
_unscaled_covzm(x::DenseMatrix, wv::AbstractWeights, dims::Integer) =
3228
_symmetrize!(unscaled_covzm(x, _scalevars(x, wv, dims), dims))
3329

src/deprecates.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if !isdefined(Base, :stderr)
55
else
66
function (io::typeof(stderr))(obj::StatisticalModel)
77
Base.depwarn("stderr(obj::StatisticalModel) is deprecated, use stderror(obj) instead", :stderr)
8-
io === stderr ? stderror(obj) : throw(MethodErrror(io, (obj,)))
8+
io === stderr ? stderror(obj) : throw(MethodError(io, (obj,)))
99
end
1010
end
1111

@@ -22,8 +22,6 @@ end
2222
@deprecate scattermatm(x::DenseMatrix, mean, wv::AbstractWeights, dims::Int) scattermat(x, wv, mean=mean, dims=dims)
2323
@deprecate scattermat(x::DenseMatrix, dims::Int) scattermat(x, dims=dims)
2424
@deprecate scattermat(x::DenseMatrix, wv::AbstractWeights, dims::Int) scattermat(x, wv, dims=dims)
25-
@deprecate scattermat_zm(x::DenseMatrix, dims::Int) scattermat_zm(x, dims=dims)
26-
@deprecate scattermat_zm(x::DenseMatrix, wv::AbstractWeights, dims::Int) scattermat_zm(x::DenseMatrix, wv::AbstractWeights, dims=dims)
2725
@deprecate mean!(R::AbstractArray, A::AbstractArray, w::AbstractWeights, dims::Int) mean!(R, A, w, dims=dims)
2826
@deprecate mean(A::AbstractArray{T}, w::AbstractWeights{W}, dims::Int) where {T<:Number,W<:Real} mean(A, w, dims=dims)
2927

src/weights.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,8 @@ function _wsum1!(R::AbstractArray, A::AbstractVector, w::AbstractVector, init::B
464464
end
465465

466466
function _wsum2_blas!(R::StridedVector{T}, A::StridedMatrix{T}, w::StridedVector{T}, dim::Int, init::Bool) where T<:BlasReal
467-
beta = ifelse(init, zero(T), one(T))
468467
trans = dim == 1 ? 'T' : 'N'
469-
BLAS.gemv!(trans, one(T), A, w, beta, R)
468+
BLAS.gemv!(trans, true, A, w, !init, R)
470469
return R
471470
end
472471

test/jet.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using StatsBase, Test
2+
import JET
3+
4+
# JET has only experimental support for Julia 1.12 currently
5+
# It throws an internal `AssertionError` in the tests below
6+
if VERSION < v"1.12-"
7+
@testset "JET" begin
8+
# Check that there are no undefined global references and undefined field accesses
9+
JET.test_package("StatsBase"; target_defined_modules = true, mode = :typo)
10+
11+
# Default error analysis for common problem fails since JET errors on interface definitions
12+
# The (deprecated) `model_response(::StatisticalModel)` calls the interface
13+
# function `response(::StatisticalModel)` for which no method exists yet
14+
# Note: This analysis is not enough strict to guarantee that there are no runtime errors!
15+
# Ref https://github.com/aviatesk/JET.jl/issues/495
16+
res = JET.report_package("StatsBase"; target_defined_modules = true, mode = :basic, toplevel_logger = nothing)
17+
println(res)
18+
reports = JET.get_reports(res)
19+
@test_broken isempty(reports)
20+
@test length(reports) <= 1
21+
end
22+
end

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ tests = ["ambiguous",
2323
"wsampling",
2424
"statmodels",
2525
"partialcor",
26-
"transformations"]
26+
"transformations",
27+
# Test with JET after all other tests since it has side effects
28+
"jet"]
2729
#"statquiz"]
2830

2931
println("Running tests:")

0 commit comments

Comments
 (0)