ChemDave commited on
Commit
a34d3c1
·
verified ·
1 Parent(s): f010787

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -0
app.py CHANGED
@@ -581,5 +581,68 @@ demo = gr.Interface(
581
  evaluate_qa_retrieval()
582
  evaluate_content_retrieval()
583
  run_regression_tests()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  demo.launch()
585
 
 
581
  evaluate_qa_retrieval()
582
  evaluate_content_retrieval()
583
  run_regression_tests()
584
+
585
+
586
+ def test_calculate_titre():
587
+ tests = [
588
+ {
589
+ "name": "Normal readings",
590
+ "initial": 0.50,
591
+ "final": 24.80,
592
+ "expected": "Titre = 24.30 cm³"
593
+ },
594
+ {
595
+ "name": "Initial reading is zero",
596
+ "initial": 0.00,
597
+ "final": 25.00,
598
+ "expected": "Titre = 25.00 cm³"
599
+ },
600
+ {
601
+ "name": "Equal readings",
602
+ "initial": 12.50,
603
+ "final": 12.50,
604
+ "expected": "Titre = 0.00 cm³"
605
+ },
606
+ {
607
+ "name": "Non-numerical input",
608
+ "initial": "abc",
609
+ "final": 24.80,
610
+ "expected": "Error"
611
+ },
612
+ {
613
+ "name": "Negative reading",
614
+ "initial": -1.00,
615
+ "final": 24.80,
616
+ "expected": "Error"
617
+ },
618
+ {
619
+ "name": "Final reading below initial",
620
+ "initial": 25.00,
621
+ "final": 20.00,
622
+ "expected": "Error"
623
+ }
624
+ ]
625
+
626
+ passed = 0
627
+
628
+ for test in tests:
629
+ result = calculate_titre(
630
+ test["initial"],
631
+ test["final"]
632
+ )
633
+
634
+ if result.startswith(test["expected"]):
635
+ print(f"PASS: {test['name']}")
636
+ passed += 1
637
+ else:
638
+ print(f"FAIL: {test['name']}")
639
+ print(f" Expected to start with: {test['expected']}")
640
+ print(f" Actual result: {result}")
641
+
642
+ print(f"\nTitre calculator: {passed}/{len(tests)} tests passed.")
643
+
644
+
645
+
646
+
647
  demo.launch()
648