MCPcopy Create free account
hub / github.com/apache/datafusion / test_cot_f32

Function test_cot_f32

datafusion/functions/src/math/cot.rs:162–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160
161 #[test]
162 fn test_cot_f32() {
163 let array = Arc::new(Float32Array::from(vec![12.1, 30.0, 90.0, -30.0]));
164 let arg_fields = vec![Field::new("a", DataType::Float32, false).into()];
165 let args = ScalarFunctionArgs {
166 args: vec![ColumnarValue::Array(Arc::clone(&array) as ArrayRef)],
167 arg_fields,
168 number_rows: array.len(),
169 return_field: Field::new("f", DataType::Float32, true).into(),
170 config_options: Arc::new(ConfigOptions::default()),
171 };
172 let result = CotFunc::new()
173 .invoke_with_args(args)
174 .expect("failed to initialize function cot");
175
176 match result {
177 ColumnarValue::Array(arr) => {
178 let floats = as_float32_array(&arr)
179 .expect("failed to convert result to a Float32Array");
180
181 let expected = Float32Array::from(vec![
182 -1.986_460_4,
183 -0.156_119_96,
184 -0.501_202_8,
185 0.156_119_96,
186 ]);
187
188 let eps = 1e-6;
189 assert_eq!(floats.len(), 4);
190 assert!((floats.value(0) - expected.value(0)).abs() < eps);
191 assert!((floats.value(1) - expected.value(1)).abs() < eps);
192 assert!((floats.value(2) - expected.value(2)).abs() < eps);
193 assert!((floats.value(3) - expected.value(3)).abs() < eps);
194 }
195 ColumnarValue::Scalar(_) => {
196 panic!("Expected an array value")
197 }
198 }
199 }
200
201 #[test]
202 fn test_cot_f64() {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
as_float32_arrayFunction · 0.85
lenMethod · 0.45
intoMethod · 0.45
invoke_with_argsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…