risk_propagation.accounts module¶
Configuration of a dictionary of bank accounts
- class risk_propagation.accounts.Accounts(accounts=None)[source]¶
Bases:
MutableMapping
[str
,Account
]Class containing a dictionary of accounts
- __delitem__(key)[source]¶
Implements deletion of an account
- Parameters:
key (
str
) – the key (label of the account) to delete- Return type:
None
- __getitem__(key)[source]¶
Enables usage of [] to get an account
- Parameters:
key (
str
) – the key (label of the account) to get- Return type:
- Returns:
the found account
- __init__(accounts=None)[source]¶
Initializes an Accounts instance
- Parameters:
accounts (
Optional
[Set
[Account
]]) – optional set of accounts to initialise with
- __setitem__(key, value)[source]¶
Enables usage of [] to set an account
- Parameters:
key (
str
) – the key (label of the account) to setvalue (
Account
) – the account to set
- Return type:
None
- encrypt(public_key)[source]¶
Encrypt all accounts
- Parameters:
public_key (
Union
[DistributedPaillier
,Paillier
]) – public key to use in the encryption- Return type:
None
- classmethod from_dataframe(dataframe, origin, delta)[source]¶
Class method to create an instance of account from a Pandas dataframe
- Parameters:
dataframe (
DataFrame
) – the dataframe to use in the initialisation with columns “id” and “score”origin (
Bank
) – the originating bankdelta (
float
) – the delta to initialise the accounts with
- Return type:
- Returns:
an Accounts instance
- Raises:
ValueError – raised when provided dataframe does not contain the correct columns