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

Function test_cot_f64

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

Source from the content-addressed store, hash-verified

200
201 #[test]
202 fn test_cot_f64() {
203 let array = Arc::new(Float64Array::from(vec![12.1, 30.0, 90.0, -30.0]));
204 let arg_fields = vec![Field::new("a", DataType::Float64, false).into()];
205 let args = ScalarFunctionArgs {
206 args: vec![ColumnarValue::Array(Arc::clone(&array) as ArrayRef)],
207 arg_fields,
208 number_rows: array.len(),
209 return_field: Field::new("f", DataType::Float64, true).into(),
210 config_options: Arc::new(ConfigOptions::default()),
211 };
212 let result = CotFunc::new()
213 .invoke_with_args(args)
214 .expect("failed to initialize function cot");
215
216 match result {
217 ColumnarValue::Array(arr) => {
218 let floats = as_float64_array(&arr)
219 .expect("failed to convert result to a Float64Array");
220
221 let expected = Float64Array::from(vec![
222 -1.986_458_685_881_4,
223 -0.156_119_952_161_6,
224 -0.501_202_783_380_1,
225 0.156_119_952_161_6,
226 ]);
227
228 let eps = 1e-12;
229 assert_eq!(floats.len(), 4);
230 assert!((floats.value(0) - expected.value(0)).abs() < eps);
231 assert!((floats.value(1) - expected.value(1)).abs() < eps);
232 assert!((floats.value(2) - expected.value(2)).abs() < eps);
233 assert!((floats.value(3) - expected.value(3)).abs() < eps);
234 }
235 ColumnarValue::Scalar(_) => {
236 panic!("Expected an array value")
237 }
238 }
239 }
240
241 #[test]
242 fn test_cot_scalar_f64() {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
as_float64_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…