Skip to content

Commit

Permalink
add val2
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowbean committed Dec 30, 2023
1 parent 19358a3 commit c8b0f94
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions absbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from absbox.deal import mkDeal, mkDealsBy, setDealsBy, prodDealsBy, setAssumpsBy, prodAssumpsBy
from absbox.local.analytics import run_yield_table, flow_by_scenario
from absbox.validation import *
from absbox.local.chart import viz
from importlib.metadata import version

__version__ = version("absbox")
9 changes: 5 additions & 4 deletions absbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

from absbox.local.util import mkTag, guess_pool_locale, mapValsBy, guess_pool_flow_header \
, _read_cf, _read_asset_pricing, mergeStrWithDict \
, earlyReturnNone, searchByFst, filter_by_tags
, earlyReturnNone, searchByFst, filter_by_tags \
, enumVals
from absbox.local.component import mkPool, mkAssumpType, mkNonPerfAssumps, mkLiqMethod \
, mkAssetUnion, mkRateAssumption
from absbox.local.base import ValidationMsg
Expand Down Expand Up @@ -71,7 +72,7 @@ class API:
url: str
lang: str = "chinese"
check: bool = True
server_info = {}
server_info: dict = {}
version = VERSION_NUM.split(".")
hdrs = {'Content-type': 'application/json', 'Accept': '*/*'
, 'Accept-Encoding': 'gzip'}
Expand Down Expand Up @@ -164,10 +165,10 @@ def run(self, deal,

rawWarnMsg = []
if multi_run_flag:
rawWarnMsgByScen = {k: [f"{MsgColor.Warning.value}{_['contents']}" for _ in filter_by_tags(v[RunResp.LogResp.value],[ValidationMsg.Warning.value, ValidationMsg.Error.value])] for k, v in result.items()}
rawWarnMsgByScen = {k: [f"{MsgColor.Warning.value}{_['contents']}" for _ in filter_by_tags(v[RunResp.LogResp.value], enumVals(ValidationMsg))] for k, v in result.items()}
rawWarnMsg = [b for a in rawWarnMsgByScen.values() for b in a]
else:
rawWarnMsg = [f"{MsgColor.Warning.value}{_['contents']}" for _ in filter_by_tags(result[RunResp.LogResp.value], [ValidationMsg.Warning.value, ValidationMsg.Error.value])]
rawWarnMsg = [f"{MsgColor.Warning.value}{_['contents']}" for _ in filter_by_tags(result[RunResp.LogResp.value], enumVals(ValidationMsg)])]

if rawWarnMsg and showWarning:
console.print("Warning Message from server:\n"+"\n".join(rawWarnMsg))
Expand Down
5 changes: 2 additions & 3 deletions absbox/local/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from absbox.local.util import mkTag,mapListValBy,mapValsBy,renameKs2\
,guess_pool_flow_header,positionFlow,mapNone\
,isMixedDeal
from absbox.local.util import earlyReturnNone
from absbox.local.component import *
from absbox.local.base import *
import pandas as pd
Expand Down Expand Up @@ -73,9 +74,7 @@ def read_assump(self, assump):
return None

def read_pricing(self, pricing):
if pricing:
return mkPricingAssump(pricing)
return None
return earlyReturnNone(mkPricingAssump, pricing)

@staticmethod
def read(resp):
Expand Down
8 changes: 3 additions & 5 deletions absbox/local/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,8 @@ def _read_cf(x, lang):
return result


def _read_asset_pricing(xs, lang):
header = assetPricingHeader[lang]
data = [x['contents'] for x in xs]
return pd.DataFrame(data, columns=header)
def _read_asset_pricing(xs, lang) -> pd.DataFrame:
return pd.DataFrame([x['contents'] for x in xs], columns=assetPricingHeader[lang])


def mergeStrWithDict(s: str, m: dict) -> str:
Expand Down Expand Up @@ -402,7 +400,7 @@ def strFromLens(x) -> str:
return str(x)


def enumVals(e):
def enumVals(e) -> list:
''' return a list of enum values '''
return [_.value for _ in [*e]]

Expand Down

0 comments on commit c8b0f94

Please sign in to comment.