@@ -425,10 +425,78 @@ def test_weibull():
425425 expected_mode_threshold )
426426
427427
428+ def test_eq ():
429+ threshold = np .arange (- 40 , 0 + 1 )
430+ slope , guess , lapse = 3.5 , 0.5 , 0.02
431+ contrasts = threshold .copy ()
432+
433+ stim_domain = dict (intensity = contrasts )
434+ param_domain = dict (threshold = threshold , slope = slope ,
435+ lower_asymptote = guess , lapse_rate = lapse )
436+ outcome_domain = dict (response = ['Correct' , 'Incorrect' ])
437+
438+ f = 'weibull'
439+ scale = 'dB'
440+ stim_selection_method = 'min_entropy'
441+ param_estimation_method = 'mode'
442+
443+ q1 = QuestPlus (stim_domain = stim_domain , param_domain = param_domain ,
444+ outcome_domain = outcome_domain , func = f , stim_scale = scale ,
445+ stim_selection_method = stim_selection_method ,
446+ param_estimation_method = param_estimation_method )
447+
448+ q2 = QuestPlus (stim_domain = stim_domain , param_domain = param_domain ,
449+ outcome_domain = outcome_domain , func = f , stim_scale = scale ,
450+ stim_selection_method = stim_selection_method ,
451+ param_estimation_method = param_estimation_method )
452+
453+ # Add some random responses.
454+ q1 .update (stim = q1 .next_stim , outcome = dict (response = 'Correct' ))
455+ q1 .update (stim = q1 .next_stim , outcome = dict (response = 'Incorrect' ))
456+ q2 .update (stim = q2 .next_stim , outcome = dict (response = 'Correct' ))
457+ q2 .update (stim = q2 .next_stim , outcome = dict (response = 'Incorrect' ))
458+
459+ assert q1 == q2
460+
461+
462+ def test_json ():
463+ threshold = np .arange (- 40 , 0 + 1 )
464+ slope , guess , lapse = 3.5 , 0.5 , 0.02
465+ contrasts = threshold .copy ()
466+
467+ stim_domain = dict (intensity = contrasts )
468+ param_domain = dict (threshold = threshold , slope = slope ,
469+ lower_asymptote = guess , lapse_rate = lapse )
470+ outcome_domain = dict (response = ['Correct' , 'Incorrect' ])
471+
472+ f = 'weibull'
473+ scale = 'dB'
474+ stim_selection_method = 'min_entropy'
475+ param_estimation_method = 'mode'
476+
477+ q = QuestPlus (stim_domain = stim_domain , param_domain = param_domain ,
478+ outcome_domain = outcome_domain , func = f , stim_scale = scale ,
479+ stim_selection_method = stim_selection_method ,
480+ param_estimation_method = param_estimation_method )
481+
482+ # Add some random responses.
483+ q .update (stim = q .next_stim , outcome = dict (response = 'Correct' ))
484+ q .update (stim = q .next_stim , outcome = dict (response = 'Incorrect' ))
485+
486+ q_dumped = q .to_json ()
487+ q_loaded = QuestPlus .from_json (q_dumped )
488+
489+ assert q_loaded == q
490+
491+ q_loaded .update (stim = q_loaded .next_stim , outcome = dict (response = 'Correct' ))
492+
493+
428494if __name__ == '__main__' :
429495 test_threshold ()
430496 test_threshold_slope ()
431497 test_threshold_slope_lapse ()
432498 test_mean_sd_lapse ()
433499 test_spatial_contrast_sensitivity ()
434500 test_weibull ()
501+ test_eq ()
502+ test_json ()
0 commit comments