Skip to content

Commit 7fa2c77

Browse files
better formatting on inits error messages
1 parent e828f4a commit 7fa2c77

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/esn/esn_inits.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ function minimal_init(rng::AbstractRNG, ::Type{T}, dims::Integer...;
251251
rng,
252252
T)
253253
else
254-
error("Sampling type not allowed. Please use one of :bernoulli or :irrational")
254+
error("""\n
255+
Sampling type not allowed.
256+
Please use one of :bernoulli or :irrational\n
257+
""")
255258
end
256259
return layer_matrix
257260
end
@@ -580,6 +583,7 @@ and scaled spectral radius according to `radius`.
580583
- `T`: Type of the elements in the reservoir matrix.
581584
Default is `Float32`.
582585
- `dims`: Dimensions of the reservoir matrix.
586+
583587
# Keyword arguments
584588
585589
- `radius`: The desired spectral radius of the reservoir.
@@ -609,7 +613,10 @@ function rand_sparse(rng::AbstractRNG, ::Type{T}, dims::Integer...;
609613
rho_w = maximum(abs.(eigvals(reservoir_matrix)))
610614
reservoir_matrix .*= radius / rho_w
611615
if Inf in unique(reservoir_matrix) || -Inf in unique(reservoir_matrix)
612-
error("Sparsity too low for size of the matrix. Increase res_size or increase sparsity")
616+
error("""\n
617+
Sparsity too low for size of the matrix.
618+
Increase res_size or increase sparsity.\n
619+
""")
613620
end
614621

615622
return return_sparse ? sparse(reservoir_matrix) : reservoir_matrix
@@ -662,8 +669,10 @@ julia> res_matrix = delay_line(5, 5; weight=1)
662669
function delay_line(rng::AbstractRNG, ::Type{T}, dims::Integer...;
663670
weight=T(0.1), return_sparse::Bool=true) where {T <: Number}
664671
reservoir_matrix = DeviceAgnostic.zeros(rng, T, dims...)
665-
@assert length(dims) == 2&&dims[1] == dims[2] "The dimensions
666-
must define a square matrix (e.g., (100, 100))"
672+
@assert length(dims) == 2&&dims[1] == dims[2] """\n
673+
The dimensions must define a square matrix
674+
(e.g., (100, 100))
675+
"""
667676

668677
for i in 1:(dims[1] - 1)
669678
reservoir_matrix[i + 1, i] = weight
@@ -687,7 +696,7 @@ Creates a matrix with backward connections as described in [^Rodan2010].
687696
Default is `Float32`.
688697
- `dims`: Dimensions of the reservoir matrix.
689698
690-
# Keyword arguments
699+
# Keyword arguments
691700
692701
- `weight`: The weight determines the absolute value of
693702
forward connections in the reservoir. Default is 0.1
@@ -818,7 +827,7 @@ Create a simple cycle reservoir with the specified dimensions and weight.
818827
- `T`: Type of the elements in the reservoir matrix. Default is `Float32`.
819828
- `dims`: Dimensions of the reservoir matrix.
820829
821-
# Keyword arguments
830+
# Keyword arguments
822831
823832
- `weight`: Weight of the connections in the reservoir matrix.
824833
Default is 0.1.
@@ -876,7 +885,7 @@ Returns an initializer to build a sparse reservoir matrix with the given
876885
Default is `Float32`.
877886
- `dims`: Dimensions of the reservoir matrix.
878887
879-
# Keyword arguments
888+
# Keyword arguments
880889
881890
- `max_value`: The maximum absolute value of elements in the matrix.
882891
Default is 1.0

0 commit comments

Comments
 (0)