Skip to content

Commit fd0a5ba

Browse files
committed
v0.2.11 Remove deployment.md and add AF92 into builtin
1 parent 98e912f commit fd0a5ba

5 files changed

Lines changed: 30 additions & 26 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ For frequently used tables, RSLife provides a preloaded cache via `MortData::fro
207207
```rust
208208
// IFOA tables
209209
let am92 = MortData::from_builtin("AM92")?;
210+
let af92 = MortData::from_builtin("AF92")?;
210211
let pfa92 = MortData::from_builtin("PFA92")?;
211212
let pma92 = MortData::from_builtin("PMA92")?;
212213

@@ -225,6 +226,7 @@ let sult = MortData::from_builtin("SULT")?;
225226
| ID | Source | Description |
226227
| :--------- | :----: | :---------------------------------------- |
227228
| `AM92` | IFOA | Male Assured Lives, 1991–94 experience |
229+
| `AF92` | IFOA | Female Assured Lives, 1991–94 experience |
228230
| `PFA92` | IFOA | Female Pensioners, 1991–94 experience |
229231
| `PMA92` | IFOA | Male Pensioners, 1991–94 experience |
230232
| `PFA92C10` | IFOA | Female Pensioners, projected to year 2010 |

src/mt_config/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub static BUILTIN_MORT_DATA: Lazy<FxHashMap<&'static str, MortData>> = Lazy::ne
2323
let mut map = FxHashMap::default();
2424

2525
// Standard IFOA tables (embedded 92series.xls etc via ifoa_xls module)
26-
for id in ["AM92", "PFA92", "PMA92"] {
26+
for id in ["AM92", "AF92", "PFA92", "PMA92"] {
2727
match MortData::from_ifoa_url_id(id) {
2828
Ok(data) => {
2929
map.insert(id, data);
File renamed without changes.

src/mt_config/mt_data.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::aga_xls::AusGovActMortXLS;
22
use super::ifoa_xls::IFOAMortXLS;
33
use super::soa_xml::SOAMortXML;
4-
use crate::RSLifeResult;
54
use crate::mt_config::spreadsheet_helpers::*;
5+
use crate::RSLifeResult;
66
use bon::bon;
7-
use calamine::{Reader, open_workbook_auto};
7+
use calamine::{open_workbook_auto, Reader};
88
use polars::prelude::*;
99
use spreadsheet_ods::read_ods;
1010
use std::fs;
@@ -586,6 +586,7 @@ impl MortData {
586586
// ========================================================
587587
// IFOA XLS PARSING
588588
// ========================================================
589+
589590
pub fn from_ifoa_xls_file_path_str(file_path: &str, sheet_name: &str) -> RSLifeResult<Self> {
590591
let data = IFOAMortXLS::from_xls_file_path_str(file_path, sheet_name)?;
591592
let result = Self::new(
@@ -626,29 +627,6 @@ impl MortData {
626627
Ok(result)
627628
}
628629

629-
// ========================================================
630-
// COMMON PRELOADED TABLES (FxHashMap cache)
631-
// ========================================================
632-
633-
/// Load a mortality table from the preloaded builtin cache.
634-
///
635-
/// Tables are loaded once at first access and cached in an `FxHashMap`.
636-
/// Subsequent calls are O(1) lookups with no I/O overhead.
637-
///
638-
/// # Supported IDs
639-
/// - IFOA: `AM92`, `PFA92`, `PMA92`
640-
/// - IFOA: `PFA92C10`, `PMA92C10`, `PFA92C20`, `PMA92C20`
641-
/// - SOA: `ELT15_F`, `ELT15_M`, `SULT`
642-
///
643-
/// # Errors
644-
/// Returns an error if the id is not in the builtin cache.
645-
pub fn from_builtin(id: &str) -> RSLifeResult<Self> {
646-
super::builtin::BUILTIN_MORT_DATA
647-
.get(id)
648-
.cloned()
649-
.ok_or_else(|| format!("Builtin mortality table '{id}' not available").into())
650-
}
651-
652630
// ========================================================
653631
// AUSTRALIAN GOVERNMENT ACTUARY XLS PARSING
654632
// ========================================================
@@ -692,6 +670,7 @@ impl MortData {
692670
// ========================================================
693671
// OTHER PARSING METHODS
694672
// ========================================================
673+
695674
/// Create mortality table from existing Polars DataFrame.
696675
///
697676
/// Convenience method to create MortData from a pre-existing DataFrame
@@ -881,6 +860,29 @@ impl MortData {
881860
"Created from XLSX file {xlsx_file_path_str}, sheet {sheet_name}.".to_string();
882861
Self::new(category, description, df)
883862
}
863+
864+
// ========================================================
865+
// COMMON PRELOADED TABLES (FxHashMap cache)
866+
// ========================================================
867+
868+
/// Load a mortality table from the preloaded builtin cache.
869+
///
870+
/// Tables are loaded once at first access and cached in an `FxHashMap`.
871+
/// Subsequent calls are O(1) lookups with no I/O overhead.
872+
///
873+
/// # Supported IDs
874+
/// - IFOA: `AM92`, `AF92`, `PFA92`, `PMA92`
875+
/// - IFOA: `PFA92C10`, `PMA92C10`, `PFA92C20`, `PMA92C20`
876+
/// - SOA: `ELT15_F`, `ELT15_M`, `SULT`
877+
///
878+
/// # Errors
879+
/// Returns an error if the id is not in the builtin cache.
880+
pub fn from_builtin(id: &str) -> RSLifeResult<Self> {
881+
super::builtin::BUILTIN_MORT_DATA
882+
.get(id)
883+
.cloned()
884+
.ok_or_else(|| format!("Builtin mortality table '{id}' not available").into())
885+
}
884886
}
885887

886888
// ================================================

0 commit comments

Comments
 (0)