Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add methods to set imp vars from imp mat * Cosmetics * Change set to calc * Ordering the code * Make init * Add haz_type as property * Add centroid columns name in exposures as property * Add overwrite variable to assign_centroids * Add method affect_values_gdf * Remove warning impf at int=0 * First commit - overhaul impact * Add insurance layers * Add methods get mdr, paa, fraction * Change sum to np.sum * Add affect_total_value * Reduce gdf to minimum necessary * Correct exposure gdf column selection * Update docstrings * Fix bug at_event / eai_exp * Refactoring of methods to simplify code * Use generator instead of list * Impact: improve performance by avoiding pandas operations * Add notimplementederror for mdf(0) * Toggle logger warning for speed test * Fetch only assigned impf * Return the reduced exp indices only * Remove 0 from insured impacts * Stich imp mat from generator * Rename impat_mat_list to _gen * Avoid generator to list conversion in insured risk * Rename exp_iimp * Add impact_calc class * Correct function signature * Adjust class name * Correct indent * Typo: stich -> stitch * PEP8 * impact: pydoc cosmetics * Include all helper methods in ImpactCalc * Remove unused module * Improve cosmetics * Improve docstring * Import new class in init * Compute insured impact from existing imp_mat if available * Make two test files * Add _return_impact method * Return impact object * Make risk_metrics a class method * Separate Impact and ImpactCalc * Add deprecation warnings * Return min exp gdf instead of df * Improve cover and deductible * Rename imp_mat to mat * Add tests for most exposed methods * Remove calc tests * Add test overwrite centroids flag * Remove warning for impf nonzero at zero * Add docstrings * Update test precision to account for different floating number * Fix bug in insure mat * Make 'imp_mat' an empty matrix by default * Use empty csr matrix instead of 'None' as default argument for 'imp_mat' in 'Impact' and 'ImpactCalc'. * Consistently check for matrix contents via its 'size' attribute. * Avoid mutables in Impact and ImpactCalc signatures * Add test case for ImpactCalc.impact_matrix Use unittest.mock to mock behavior of hazard object. * Add input attribute consistency checks to init * Add unfinished impact init test * Set default imp_mat to None * Update init consistency tests * Add from_eih test * Add test risk transfer and residual risk * Add test impact_per_year * Cosmetics * Remove unsued method * Add test for affected value * Add property tests * Add test get_mdr * Add test get paa * Add test get fraction * Add docstring * Add chunk method * Update name cent to centr * Update docstring * Use np.array_split for chunks * Update naming * Simplify argument chunker * Add test case for ImpactCalc.imp_mat_gen * Add test for ImpactCalc.stitch_impact_matrix * Add test for ImpactCalc.apply_deductible_to_mat * Fix bug and formatting in ImpactCalc.imp_mat_gen * Use the original impf_id instead of relying on the ID of the returned impact function object. * Remove superfluous whitespace * Add test with fraction not equal 1 * Improve error message in impact matrix chunking * test_impact_calc: persistently revert the CONFIG changes in tearDown * Replace instances in CONFIG instead of mocking Explicitly replace instances in the CONFIG tree with new/old values in the TestImpactMatrixGenerator test case, because CONFIG cannot be deepcopied. This avoids errors in tests that are executed after this test case. * Add test for ImpactCalc.stitch_risk_metrics and update docstring * Add deepcopy import to test_impact_calc * Add test for ImpactCalc.insured_mat_gen and update docstring * Add test for ImpactCalc.impact_matrix * Add TestInsuredImpactMatrixGenerator to test loader The test was previously not added to the loader, but this only had an effect when the file was executed directly (as __main__). * Add test for ImpactCalc._return_matrix * Update docstring * pydoc cosmetics * pydoc cosmetics * pydoc consolidation * Improve attribute error message from_eih * Update from_eih tests * impact_calc.ImpactCalc: remove imp_mat attribute turn n_exp_pnt and n_events into properties set cover and deductible to None if not set (instead of an empty array) * ImpactCalc.impact: re-establish save_mat argument * Set assigned_centroids overwrite=False * (Re)-Set ignore zero to False * Update deprecation warning message * Correct bug wrong exp_idx The exposures index from the impact matrix generator was indexed for the reduced exposures only, instead of the total exposures. This leads to wrong indexing. * Make new index in case the index is not ordered * Slice numpy instead of gdf * Add _orig_exp_idx to tests * Add tests with Flood * Return empty impact if no exposures matching hazard * Repalce squeeze by ravel for atevent single event * Add _orig_exp_idx as argument from beginning on * Update comment cosmetics * Reduce lines to max length * Replace generator by list due to deprecation in np.hstack * test_impact_calc: organize test data Co-authored-by: Chahan Kropf <chahan.kropf@posteo.com> Co-authored-by: Thomas Vogt <thomas.vogt@pik-potsdam.de> Co-authored-by: emanuel-schmid <schmide@ethz.ch> Co-authored-by: Lukas Riedel <34276446+peanutfun@users.noreply.github.com>
- Loading branch information