@@ -87,7 +87,10 @@ function hadi1992(multivariateData::AbstractMatrix{Float64}; alpha = 0.05)
8787 Sm = (1.0 / (n - 1.0 )) * (multivariateData .- meds' )' * (multivariateData .- meds' )
8888
8989 msm1 = mahalanobisSquaredMatrix (multivariateData, meanvector = meds, covmatrix = Sm)
90- @assert ! isnothing (msm1)
90+
91+ if isnothing (msm1)
92+ throw (ErrorException (" Mahalanobis distances are not calculated" ))
93+ end
9194
9295 mah0 = diag (msm1)
9396
@@ -99,7 +102,10 @@ function hadi1992(multivariateData::AbstractMatrix{Float64}; alpha = 0.05)
99102 Sv = (1.0 / (h - 1.0 )) * (starting_data .- Cv' )' * (starting_data .- Cv' )
100103
101104 msm2 = mahalanobisSquaredMatrix (multivariateData, meanvector = Cv, covmatrix = Sv)
102- @assert ! isnothing (msm2)
105+
106+ if isnothing (msm2)
107+ throw (ErrorException (" Mahalanobis distances are not calculated" ))
108+ end
103109
104110 mah1 = diag (msm2)
105111 ordering_indices_mah1 = sortperm (mah1)
@@ -130,15 +136,22 @@ function hadi1992(multivariateData::AbstractMatrix{Float64}; alpha = 0.05)
130136 newSb .= hadi1992_handle_singularity (cfactor * Sb)
131137
132138 msm3 .= mahalanobisSquaredMatrix (multivariateData, meanvector = Cb, covmatrix = newSb,)
133- @assert ! isnothing (msm3)
139+
140+ if isnothing (msm3)
141+ throw (ErrorException (" Mahalanobis distances are not calculated" ))
142+ end
134143
135144 mah1 .= diag (msm3)
136145
137146 ordering_indices_mah1 = sortperm (mah1)
138147 basic_subset_indices = ordering_indices_mah1[1 : r]
139148 else
140149 msm4 .= mahalanobisSquaredMatrix (multivariateData, meanvector = Cb, covmatrix = (cfactor * Sb))
141- @assert ! isnothing (msm4)
150+
151+ if isnothing (msm4)
152+ throw (ErrorException (" Mahalanobis distances are not calculated" ))
153+ end
154+
142155 mah1 .= diag (msm4)
143156 ordering_indices_mah1 = sortperm (mah1)
144157 basic_subset_indices = ordering_indices_mah1[1 : r]
0 commit comments