MCPcopy Create free account
hub / github.com/Derive-Risk/pyfair / test_exports

Method test_exports

tests/model/test_model.py:111–131  ·  view source on GitHub ↗

Test outputs post calculation

(self)

Source from the content-addressed store, hash-verified

109 model.calculate_all()
110
111 def test_exports(self):
112 """Test outputs post calculation"""
113 # Create model and calculate
114 model = FairModel('Test', self.N_SAMPLES)
115 model.bulk_import_data({
116 'Loss Magnitude': {'constant': 100},
117 'Loss Event Frequency': {'low': 10, 'mode': 15, 'high': 20}
118 })
119 model.calculate_all()
120 # Export results
121 results = model.export_results()
122 self.assertIsInstance(results, pd.DataFrame)
123 self.assertTrue(len(results) == self.N_SAMPLES)
124 # Export json and ensure parse-able
125 json_data = model.to_json()
126 self.assertIsInstance(json_data, str)
127 _ = json.loads(json_data)
128 # Export params
129 params = model.export_params()
130 self.assertIsInstance(params, dict)
131 self.assertTrue(params)
132
133
134if __name__ == '__main__':

Callers

nothing calls this directly

Calls 6

bulk_import_dataMethod · 0.95
calculate_allMethod · 0.95
export_resultsMethod · 0.95
to_jsonMethod · 0.95
export_paramsMethod · 0.95
FairModelClass · 0.90

Tested by

no test coverage detected