@@ -20,9 +20,6 @@ function vec_of_vecs(X::AbstractMatrix; obsdim::Int = 2)
20
20
end
21
21
end
22
22
23
- dim (x:: AbstractVector{<:AbstractVector{<:Real}} ) = length (first (x))
24
- dim (x:: AbstractVector{Tuple{Any,Int}} ) = 1
25
-
26
23
"""
27
24
ColVecs(X::AbstractMatrix)
28
25
@@ -94,6 +91,21 @@ For a transform return its parameters, for a `ChainTransform` return a vector of
94
91
"""
95
92
# params
96
93
94
+ dim (x) = 0
95
+ dim (x:: AbstractVector{<:AbstractVector{<:Real}} ) = length (first (x))
96
+ dim (x:: AbstractVector{<:Real} ) = 1
97
+ dim (x:: AbstractVector{Tuple{Any,Int}} ) = 1
98
+
99
+
100
+ function validate_inputs (x, y)
101
+ if dim (x) != dim (y) # Passes by default if `dim` is not defined
102
+ throw (DimensionMismatch (
103
+ " Dimensionality of x ($(dim (x)) ) not equality to that of y ($(dim (y)) )" ,
104
+ ))
105
+ end
106
+ return nothing
107
+ end
108
+
97
109
98
110
function validate_inplace_dims (K:: AbstractMatrix , x:: AbstractVector , y:: AbstractVector )
99
111
validate_inputs (x, y)
@@ -117,13 +129,3 @@ function validate_inplace_dims(K::AbstractVector, x::AbstractVector)
117
129
))
118
130
end
119
131
end
120
-
121
- validate_inputs (x, y) = nothing
122
-
123
- function validate_inputs (x:: V , y:: V ) where {V<: Union{RowVecs, ColVecs, AbstractVector{<:AbstractVector{<:Real}}} }
124
- if dim (x) != dim (y)
125
- throw (DimensionMismatch (
126
- " Dimensionality of x ($(dim (x)) ) not equality to that of y ($(dim (y)) )" ,
127
- ))
128
- end
129
- end
0 commit comments