File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 22name = " smartcore"
33description = " Machine Learning in Rust."
44homepage = " https://smartcorelib.org"
5- version = " 0.4.3 "
5+ version = " 0.4.4 "
66authors = [" smartcore Developers" ]
77edition = " 2021"
88license = " Apache-2.0"
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ impl<T: Number> Cosine<T> {
9292 let magnitude_y = Self :: magnitude ( y) ;
9393
9494 if magnitude_x == 0.0 || magnitude_y == 0.0 {
95- panic ! ( "Cannot compute cosine distance for zero-magnitude vectors." ) ;
95+ return f64 :: MIN ;
9696 }
9797
9898 dot_product / ( magnitude_x * magnitude_y)
@@ -188,12 +188,12 @@ mod tests {
188188 wasm_bindgen_test:: wasm_bindgen_test
189189 ) ]
190190 #[ test]
191- #[ should_panic( expected = "Cannot compute cosine distance for zero-magnitude vectors." ) ]
192191 fn cosine_distance_zero_vector ( ) {
193192 let a = vec ! [ 0 , 0 , 0 ] ;
194193 let b = vec ! [ 1 , 2 , 3 ] ;
195194
196- let _dist: f64 = Cosine :: new ( ) . distance ( & a, & b) ;
195+ let dist: f64 = Cosine :: new ( ) . distance ( & a, & b) ;
196+ assert ! ( dist > 1e300 )
197197 }
198198
199199 #[ cfg_attr(
You can’t perform that action at this time.
0 commit comments