@@ -85,20 +85,61 @@ def setup_module(module):
85
85
def test_cyice_b1900_correctness ():
86
86
assert cyice .b1900 () == 2415020.31352
87
87
88
+
88
89
@pytest .mark .parametrize ('function' , [cyice .b1900 , spice .b1900 ], ids = get_module_name )
89
90
@pytest .mark .parametrize ('grouped_benchmark' , ["b1900" ], indirect = True )
90
91
def test_perf_b1900 (function , grouped_benchmark ):
91
92
grouped_benchmark (function )
92
93
93
94
94
- def test_cyice_convrt_correctness ():
95
- assert cyice .convrt (300.0 , "statute_miles" , "km" ) == 482.80320
95
+ @pytest .mark .parametrize ('function' , [cyice .ckgp , spice .ckgp ], ids = get_module_name )
96
+ @pytest .mark .parametrize ('grouped_benchmark' , ["ckgp" ], indirect = True )
97
+ def test_perf_ckgp (function , grouped_benchmark , load_cassini_kernels ):
98
+ ckid = - 82000
99
+ cover = 267832537952.0
100
+ grouped_benchmark (function , ckid , cover , 256 , "J2000" )
101
+ res = function (ckid , cover , 256 , "J2000" )
102
+ cmat , clkout = res [0 ], res [1 ]
103
+ assert clkout == 267832537952.0
104
+ assert isinstance (cmat , np .ndarray )
105
+ expected_cmat = [
106
+ [0.5064665782997639365 , - 0.75794210739897316387 , 0.41111478554891744963 ],
107
+ [- 0.42372128242505308071 , 0.19647683351734512858 , 0.88422685364733510927 ],
108
+ [- 0.7509672961490383436 , - 0.6220294331642198804 , - 0.22164725216433822652 ],
109
+ ]
110
+ npt .assert_array_almost_equal (cmat , expected_cmat )
111
+
112
+
113
+ @pytest .mark .parametrize ('function' , [cyice .ckgpav , spice .ckgpav ], ids = get_module_name )
114
+ @pytest .mark .parametrize ('grouped_benchmark' , ["ckgpav" ], indirect = True )
115
+ def test_perf_ckgpav (function , grouped_benchmark , load_cassini_kernels ):
116
+ ckid = - 82000
117
+ cover = 267832537952.0
118
+ grouped_benchmark (function , ckid , cover , 256 , "J2000" )
119
+ res = function (ckid , cover , 256 , "J2000" )
120
+ cmat , avout , clkout = res [0 ], res [1 ], res [2 ]
121
+ assert clkout == 267832537952.0
122
+ assert isinstance (cmat , np .ndarray )
123
+ assert isinstance (avout , np .ndarray )
124
+ expected_cmat = [
125
+ [0.5064665782997639365 , - 0.75794210739897316387 , 0.41111478554891744963 ],
126
+ [- 0.42372128242505308071 , 0.19647683351734512858 , 0.88422685364733510927 ],
127
+ [- 0.7509672961490383436 , - 0.6220294331642198804 , - 0.22164725216433822652 ],
128
+ ]
129
+ expected_avout = [
130
+ - 0.00231258422150853885 ,
131
+ - 0.00190333614370416515 ,
132
+ - 0.00069657429072504716 ,
133
+ ]
134
+ npt .assert_array_almost_equal (cmat , expected_cmat )
135
+ npt .assert_array_almost_equal (avout , expected_avout )
96
136
97
137
98
138
@pytest .mark .parametrize ('function' , [cyice .convrt , spice .convrt ], ids = get_module_name )
99
139
@pytest .mark .parametrize ('grouped_benchmark' , ["convrt" ], indirect = True )
100
140
def test_perf_convrt (function , grouped_benchmark ):
101
141
grouped_benchmark (function , 1.0 , "parsecs" , "lightyears" )
142
+ assert function (300.0 , "statute_miles" , "km" ) == 482.80320
102
143
103
144
104
145
@pytest .mark .parametrize ('function' , [cyice .convrt_v , spice .convrt ], ids = get_module_name )
@@ -120,11 +161,14 @@ def test_perf_deltet(function, grouped_benchmark, load_core_kernels):
120
161
def test_perf_deltet_v (function , grouped_benchmark , load_core_kernels ):
121
162
ets_2004 = np .repeat (spice .str2et ("Jan 1 2004" ), 100 )
122
163
grouped_benchmark (function , ets_2004 , "ET" )
164
+ res = function (ets_2004 , "ET" )
165
+ assert isinstance (res , np .ndarray )
123
166
124
167
125
168
def test_cyice_et2utc_v_correctness (load_core_kernels ):
126
169
et = - 527644192.5403653
127
170
output = cyice .et2utc_v (np .array ([et ] * 100 ), "J" , 6 )
171
+ assert isinstance (output , list )
128
172
assert np .array_equal (
129
173
output ,
130
174
np .array (["JD 2445438.006415" ] * 100 ),
@@ -155,6 +199,8 @@ def test_perf_etcal(function, grouped_benchmark):
155
199
def test_perf_etcal_v (function , grouped_benchmark ):
156
200
data = np .arange (10000.0 , dtype = float )
157
201
grouped_benchmark (function , data )
202
+ res = function (data )
203
+ assert isinstance (res , np .ndarray )
158
204
159
205
160
206
@pytest .mark .parametrize ('function' , [cyice .failed , spice .failed ], ids = get_module_name )
@@ -172,13 +218,36 @@ def test_perf_fovray(function, grouped_benchmark, load_cassini_kernels):
172
218
et = spice .str2et ("2013 FEB 25 11:50:00 UTC" )
173
219
raydir = np .array ([0.0 , 0.0 , 1.0 ])
174
220
grouped_benchmark (function , "CASSINI_ISS_NAC" , raydir , frame , "S" , "CASSINI" , et )
221
+ assert function ("CASSINI_ISS_NAC" , raydir , frame , "S" , "CASSINI" , et )
222
+
223
+
224
+ @pytest .mark .parametrize ('function' , [cyice .fovray_v ], ids = get_module_name )
225
+ @pytest .mark .parametrize ('grouped_benchmark' , ["fovray_v" ], indirect = True )
226
+ def test_perf_fovray_v (function , grouped_benchmark , load_cassini_kernels ):
227
+ # core of test
228
+ ets = np .repeat (spice .str2et ("2013 FEB 25 11:50:00 UTC" ), 100 )
229
+ raydir = np .array ([0.0 , 0.0 , 1.0 ])
230
+ grouped_benchmark (function , "CASSINI_ISS_NAC" , raydir , "CASSINI_ISS_NAC" , "S" , "CASSINI" , ets )
231
+ res = function ("CASSINI_ISS_NAC" , raydir , "CASSINI_ISS_NAC" , "S" , "CASSINI" , ets )
232
+ assert isinstance (res , np .ndarray )
233
+ assert res .dtype == np .bool
175
234
176
235
177
236
@pytest .mark .parametrize ('function' , [cyice .fovtrg , spice .fovtrg ], ids = get_module_name )
178
237
@pytest .mark .parametrize ('grouped_benchmark' , ["fovtrg" ], indirect = True )
179
- def test_perf_fovray (function , grouped_benchmark , load_cassini_kernels ):
238
+ def test_perf_fovtrg (function , grouped_benchmark , load_cassini_kernels ):
180
239
et = spice .str2et ("2013 FEB 25 11:50:00 UTC" )
181
- grouped_benchmark (function , "CASSINI_ISS_NAC" ,"Enceladus" , "Ellipsoid" , "IAU_ENCELADUS" , "LT+S" ,"CASSINI" , et )
240
+ grouped_benchmark (function , "CASSINI_ISS_NAC" , "Enceladus" , "Ellipsoid" , "IAU_ENCELADUS" , "LT+S" ,"CASSINI" , et )
241
+
242
+
243
+ @pytest .mark .parametrize ('function' , [cyice .fovtrg_v ], ids = get_module_name )
244
+ @pytest .mark .parametrize ('grouped_benchmark' , ["fovtrg_v" ], indirect = True )
245
+ def test_perf_fovtrg_v (function , grouped_benchmark , load_cassini_kernels ):
246
+ ets = np .repeat (spice .str2et ("2013 FEB 25 11:50:00 UTC" ), 100 )
247
+ grouped_benchmark (function , "CASSINI_ISS_NAC" ,"Enceladus" , "Ellipsoid" , "IAU_ENCELADUS" , "LT+S" ,"CASSINI" , ets )
248
+ res = function ( "CASSINI_ISS_NAC" ,"Enceladus" , "Ellipsoid" , "IAU_ENCELADUS" , "LT+S" ,"CASSINI" , ets )
249
+ assert isinstance (res , np .ndarray )
250
+ assert res .dtype == np .bool
182
251
183
252
184
253
@pytest .mark .parametrize ('function' , [cyice .lspcn , spice .lspcn ], ids = get_module_name )
@@ -217,6 +286,7 @@ def test_cyice_spkcvt_correctness(load_earth_kernels):
217
286
1.11355285621839659171e01 ,
218
287
])
219
288
npt .assert_almost_equal (lt , expected_lt )
289
+ assert isinstance (state , np .ndarray )
220
290
npt .assert_array_almost_equal (state , expected_state , decimal = 6 )
221
291
222
292
@@ -255,14 +325,13 @@ def test_perf_sce2c(function, grouped_benchmark, load_voyager_kernels):
255
325
grouped_benchmark (function , - 32 , et )
256
326
257
327
258
- # @pytest.mark.skip(reason="broken")
259
- # @pytest.mark.parametrize('function', [cyice.sce2s, spice.sce2s])
260
- # def test_perf_sce2s(function, benchmark):
261
- # benchmark.group = 'performance - %s' % get_qualified_name(function)
262
- # spice.furnsh(CoreKernels.testMetaKernel)
263
- # spice.furnsh(ExtraKernels.voyagerSclk)
264
- # et = spice.str2et("1979 JUL 05 21:50:21.23379")
265
- # benchmark(function, -32, et)
328
+ @pytest .mark .parametrize ('function' , [cyice .sce2s , spice .sce2s ], ids = get_module_name )
329
+ @pytest .mark .parametrize ('grouped_benchmark' , ["sce2s" ], indirect = True )
330
+ def test_perf_sce2s (function , grouped_benchmark ):
331
+ spice .furnsh (CoreKernels .testMetaKernel )
332
+ spice .furnsh (ExtraKernels .voyagerSclk )
333
+ et = spice .str2et ("1979 JUL 05 21:50:21.23379" )
334
+ grouped_benchmark (function , - 32 , et )
266
335
267
336
268
337
@pytest .mark .parametrize ('function' , [cyice .scs2e , spice .scs2e ], ids = get_module_name )
@@ -276,72 +345,66 @@ def test_perf_scs2e(function, grouped_benchmark, load_voyager_kernels):
276
345
def test_perf_sct2e (function , grouped_benchmark , load_voyager_kernels ):
277
346
grouped_benchmark (function , - 32 , 985327965.0 )
278
347
279
- # # def test_getmsg_cyice_benchmark(benchmark):
280
- # # cyice.reset()
281
- # # spice.sigerr("test error")
282
- # # benchmark(cyice.getmsg, "SHORT", 200)
283
- # # cyice.reset()
284
-
285
-
286
- # # def test_getmsg_spiceypy_benchmark(benchmark):
287
- # # spice.reset()
288
- # # spice.sigerr("test error")
289
- # # benchmark(spice.getmsg, "SHORT", 200)
290
- # # spice.reset()
291
-
292
-
293
- # # def test_qcktrc():
294
- # # cyice.reset()
295
- # # spice.chkin("test")
296
- # # spice.chkin("qcktrc")
297
- # # trace = cyice.qcktrc(40)
298
- # # assert trace == "test --> qcktrc"
299
- # # spice.chkout("qcktrc")
300
- # # spice.chkout("test")
301
- # # cyice.reset()
302
-
303
348
304
- # # def test_qcktrc_cyice_benchmark(benchmark):
305
- # # cyice.reset()
306
- # # spice.chkin("test")
307
- # # spice.chkin("qcktrc")
308
- # # benchmark(cyice.qcktrc, 40)
309
- # # spice.chkout("qcktrc")
310
- # # spice.chkout("test")
311
- # # cyice.reset()
349
+ @pytest .mark .parametrize ('function' , [cyice .getmsg , spice .getmsg ], ids = get_module_name )
350
+ @pytest .mark .parametrize ('grouped_benchmark' , ["getmsg" ], indirect = True )
351
+ def test_perf_getmsg (function , grouped_benchmark ):
352
+ cyice .reset ()
353
+ spice .sigerr ("test error" )
354
+ grouped_benchmark (function , "SHORT" , 200 )
355
+ cyice .reset ()
312
356
313
357
314
- # # def test_qcktrc_spiceypy_benchmark(benchmark):
315
- # # spice.reset()
316
- # # spice.chkin("test")
317
- # # spice.chkin("qcktrc")
318
- # # benchmark(spice.qcktrc, 40)
319
- # # spice.chkout("qcktrc")
320
- # # spice.chkout("test")
321
- # # spice.reset()
358
+ @pytest .mark .parametrize ('function' , [cyice .qcktrc , spice .qcktrc ], ids = get_module_name )
359
+ @pytest .mark .parametrize ('grouped_benchmark' , ["qcktrc" ], indirect = True )
360
+ def test_perf_qcktrc (function , grouped_benchmark ):
361
+ cyice .reset ()
362
+ spice .chkin ("test" )
363
+ spice .chkin ("qcktrc" )
364
+ grouped_benchmark (function , 40 )
365
+ trace = function (40 )
366
+ assert trace == "test --> qcktrc"
367
+ spice .chkout ("qcktrc" )
368
+ spice .chkout ("test" )
369
+ cyice .reset ()
322
370
323
371
324
372
@pytest .mark .parametrize ('function' , [cyice .spkez , spice .spkez ], ids = get_module_name )
325
373
@pytest .mark .parametrize ('grouped_benchmark' , ["spkez" ], indirect = True )
326
374
def test_perf_spkez (function , grouped_benchmark , load_core_kernels ):
327
375
et = cyice .str2et ("July 4, 2003 11:00 AM PST" )
328
376
grouped_benchmark (function , 499 , et , "J2000" , "LT+S" , 399 )
377
+ state , lt = function (499 , et , "J2000" , "LT+S" , 399 )
378
+ assert isinstance (state , np .ndarray )
329
379
330
380
381
+ @pytest .mark .parametrize ('function' , [cyice .spkez_v ], ids = get_module_name )
382
+ @pytest .mark .parametrize ('grouped_benchmark' , ["spkez_v" ], indirect = True )
383
+ def test_perf_spkez_v (function , grouped_benchmark , load_core_kernels ):
384
+ ets = np .repeat (cyice .str2et ("July 4, 2003 11:00 AM PST" ), 100 )
385
+ grouped_benchmark (function , 499 , ets , "J2000" , "LT+S" , 399 )
386
+ state , lts = function (499 , ets , "J2000" , "LT+S" , 399 )
387
+ assert isinstance (state , np .ndarray )
388
+ assert isinstance (lts , np .ndarray )
389
+
331
390
332
391
@pytest .mark .parametrize ('function' , [cyice .spkezr , spice .spkezr ], ids = get_module_name )
333
392
@pytest .mark .parametrize ('grouped_benchmark' , ["spkezr" ], indirect = True )
334
393
def test_perf_spkezr (function , grouped_benchmark , load_core_kernels ):
335
394
et = cyice .str2et ("July 4, 2003 11:00 AM PST" )
336
395
grouped_benchmark (function , "Mars" , et , "J2000" , "LT+S" , "Earth" )
396
+ state , lt = function ("Mars" , et , "J2000" , "LT+S" , "Earth" )
397
+ assert isinstance (state , np .ndarray )
337
398
338
399
339
400
@pytest .mark .parametrize ('function' , [cyice .spkezr_v , spice .spkezr ], ids = get_module_name )
340
401
@pytest .mark .parametrize ('grouped_benchmark' , ["spkezr_v" ], indirect = True )
341
402
def test_perf_spkezr_v (function , grouped_benchmark , load_core_kernels ):
342
403
ets = np .full ((100 ,), spice .str2et ("July 4, 2003 11:00 AM PST" ))
343
404
grouped_benchmark (function , "Mars" , ets , "J2000" , "LT+S" , "Earth" )
344
- state , lt = function ("Mars" , ets , "J2000" , "LT+S" , "Earth" )
405
+ state , lts = function ("Mars" , ets , "J2000" , "LT+S" , "Earth" )
406
+ assert isinstance (lts , np .ndarray )
407
+ assert isinstance (state , np .ndarray )
345
408
expected_lt = np .full ((100 ,), 269.6898816177049 )
346
409
expected_state = np .full (
347
410
(100 , 6 ),
@@ -354,7 +417,7 @@ def test_perf_spkezr_v(function, grouped_benchmark, load_core_kernels):
354
417
3.001298515816776 ,
355
418
],
356
419
)
357
- npt .assert_allclose (lt , expected_lt )
420
+ npt .assert_allclose (lts , expected_lt )
358
421
npt .assert_allclose (state , expected_state )
359
422
360
423
@@ -371,13 +434,16 @@ def test_perf_spkpos_v(function, grouped_benchmark, load_core_kernels):
371
434
_et = spice .str2et (["July 4, 2003 11:00 AM PST" , "July 11, 2003 11:10 AM PST" ])
372
435
et = np .linspace (_et [0 ], _et [1 ], num = 100 )
373
436
grouped_benchmark (function , "Mars" , et , "J2000" , "LT+S" , "Earth" )
437
+ ptargs , lts = function ("Mars" , et , "J2000" , "LT+S" , "Earth" )
438
+ assert isinstance (ptargs , np .ndarray )
374
439
375
440
376
441
@pytest .mark .parametrize ('function' , [cyice .str2et , spice .str2et ], ids = get_module_name )
377
442
@pytest .mark .parametrize ('grouped_benchmark' , ["str2et" ], indirect = True )
378
443
def test_perf_str2et (function , grouped_benchmark , load_core_kernels ):
379
444
grouped_benchmark (function , "Thu Mar 20 12:53:29 PST 1997" )
380
445
446
+
381
447
@pytest .mark .parametrize ('function' , [cyice .str2et_v , spice .str2et ], ids = get_module_name )
382
448
@pytest .mark .parametrize ('grouped_benchmark' , ["str2et_v" ], indirect = True )
383
449
def test_perf_str2et_v (function , grouped_benchmark , load_core_kernels ):
@@ -386,6 +452,7 @@ def test_perf_str2et_v(function, grouped_benchmark, load_core_kernels):
386
452
grouped_benchmark (function , dates )
387
453
expected_ets = np .ones (100 ) * - 87836728.81438904
388
454
ets = function (dates )
455
+ assert isinstance (ets , np .ndarray )
389
456
npt .assert_array_almost_equal (ets , expected_ets )
390
457
391
458
@@ -406,6 +473,7 @@ def test_perf_sxform(function, grouped_benchmark, load_core_kernels):
406
473
estate = spice .georec (lon , lat , alt , equatr , f )
407
474
estate = np .append (estate , [0.0 , 0.0 , 0.0 ])
408
475
xform = cyice .sxform ("IAU_EARTH" , "J2000" , et )
476
+ assert isinstance (xform , np .ndarray )
409
477
jstate = np .dot (xform , estate )
410
478
expected = np .array (
411
479
[
@@ -425,6 +493,8 @@ def test_perf_sxform(function, grouped_benchmark, load_core_kernels):
425
493
def test_perf_sxform_v (function , grouped_benchmark , load_core_kernels ):
426
494
et = np .repeat (spice .str2et ("January 1, 1990" ), 1000 )
427
495
grouped_benchmark (function , "IAU_EARTH" , "J2000" , et )
496
+ res = function ("IAU_EARTH" , "J2000" , et )
497
+ assert isinstance (res , np .ndarray )
428
498
429
499
430
500
@pytest .mark .parametrize ('function' , [cyice .tangpt , spice .tangpt ], ids = get_module_name )
@@ -451,6 +521,8 @@ def test_perf_tangpt(function, grouped_benchmark, load_core_kernels):
451
521
tanpt , alt , range , srfpt , trgepc , srfvec = spice .tangpt (
452
522
"ELLIPSOID" , target , et , fixref , "NONE" , locus , obsrvr , rayfrm , raydir
453
523
)
524
+ assert isinstance (tanpt , np .ndarray )
525
+ assert isinstance (srfpt , np .ndarray )
454
526
npt .assert_array_almost_equal (
455
527
tanpt , [- 113646.428171 , 213634.489363 , - 222709.965702 ], decimal = 5
456
528
)
@@ -461,6 +533,7 @@ def test_perf_tangpt(function, grouped_benchmark, load_core_kernels):
461
533
)
462
534
assert trgepc == pytest .approx (414026480.213872 )
463
535
536
+
464
537
@pytest .mark .parametrize ('function' , [cyice .trgsep , spice .trgsep ], ids = get_module_name )
465
538
@pytest .mark .parametrize ('grouped_benchmark' , ["trgsep" ], indirect = True )
466
539
def test_perf_trgsep (function , grouped_benchmark , load_core_kernels ):
@@ -469,11 +542,14 @@ def test_perf_trgsep(function, grouped_benchmark, load_core_kernels):
469
542
point_sep = function (et , "MOON" , "POINT" , "IAU_MOON" , "EARTH" , "POINT" , "IAU_EARTH" , "SUN" , "LT+S" )
470
543
assert spice .dpr () * point_sep == pytest .approx (0.15729276 )
471
544
545
+
472
546
@pytest .mark .parametrize ('function' , [cyice .trgsep_v ,], ids = get_module_name )
473
547
@pytest .mark .parametrize ('grouped_benchmark' , ["trgsep_v" ], indirect = True )
474
548
def test_perf_trgsep_v (function , grouped_benchmark , load_core_kernels ):
475
549
ets = np .repeat (spice .str2et ("2007-JAN-11 11:21:20.213872 (TDB)" ),100 )
476
550
grouped_benchmark (function , ets , "MOON" , "POINT" , "IAU_MOON" , "EARTH" , "POINT" , "IAU_EARTH" , "SUN" , "LT+S" )
551
+ res = function (ets , "MOON" , "POINT" , "IAU_MOON" , "EARTH" , "POINT" , "IAU_EARTH" , "SUN" , "LT+S" )
552
+ assert isinstance (res , np .ndarray )
477
553
478
554
479
555
@pytest .mark .parametrize ('function' , [cyice .unitim , spice .unitim ], ids = get_module_name )
@@ -491,17 +567,22 @@ def test_perf_unitim(function, grouped_benchmark, load_core_kernels):
491
567
def test_perf_unitim_v (function , grouped_benchmark , load_core_kernels ):
492
568
ets = np .repeat (spice .str2et ("Dec 19 2003" ), 100 )
493
569
grouped_benchmark (function , ets , "ET" , "JED" )
570
+ res = function (ets , "ET" , "JED" )
571
+ assert isinstance (res , np .ndarray )
494
572
495
573
496
574
@pytest .mark .parametrize ('function' , [cyice .utc2et , spice .utc2et ], ids = get_module_name )
497
575
@pytest .mark .parametrize ('grouped_benchmark' , ["utc2et" ], indirect = True )
498
576
def test_perf_utc2et (function , grouped_benchmark , load_core_kernels ):
499
577
grouped_benchmark (function , "December 1, 2004 15:04:11" )
578
+ assert function ("December 1, 2004 15:04:11" ) == 155185515.1831043
500
579
501
580
502
581
@pytest .mark .parametrize ('function' , [cyice .utc2et_v ], ids = get_module_name )
503
582
@pytest .mark .parametrize ('grouped_benchmark' , ["utc2et_v" ], indirect = True )
504
583
def test_perf_utc2et_v (function , grouped_benchmark , load_core_kernels ):
505
584
date = "December 1, 2004 15:04:11"
506
585
dates = np .array ([date ] * 100 , dtype = np .str_ )
507
- grouped_benchmark (function , dates )
586
+ grouped_benchmark (function , dates )
587
+ res = function (dates )
588
+ assert isinstance (res , np .ndarray )
0 commit comments