Guidance basis label: only guidance rows with typed values (a trigger may cite a plain metric claim)
Browse filesFiles changed (2)
575 unmodified lines576577578579580581582583584585586575 unmodified linesdef guidance_basis_label(cat, cid):"""'GAAP' / 'adjusted' when a guidance row has a sibling of the same concept on another basis with a differentvalue (the basis then decides which figure is meant); None when the basis does not change the figure."""v = (cat.get(cid).value or {}) if cat.get(cid) is not None else {}if not v.get("concept"):return Nonesib = {(x.get("accounting_basis"), x.get("low"), x.get("high")) for x in((c.value or {}) for k, c in cat.items() if k.startswith("GUIDANCE_")) if x.get("concept") == v["concept"]}if len({(lo, hi) for _b, lo, hi in sib}) > 1 and len({b for b, _lo, _hi in sib}) > 1:return {"GAAP": "GAAP", "ADJUSTED": "adjusted"}.get(v.get("accounting_basis"))return None575 unmodified lines576577578579580581582583584585586587588589575 unmodified linesdef guidance_basis_label(cat, cid):"""'GAAP' / 'adjusted' when a guidance row has a sibling of the same concept on another basis with a differentvalue (the basis then decides which figure is meant); None when the basis does not change the figure."""from collections.abc import Mappingc0 = cat.get(cid) if str(cid or "").startswith("GUIDANCE_") else None # only a guidance row has a basisv = c0.value if c0 is not None and isinstance(c0.value, Mapping) else {}if not v.get("concept"):return Nonesib = {(x.get("accounting_basis"), x.get("low"), x.get("high")) for x in(c.value for k, c in cat.items() if k.startswith("GUIDANCE_") and isinstance(c.value, Mapping))if x.get("concept") == v["concept"]}if len({(lo, hi) for _b, lo, hi in sib}) > 1 and len({b for b, _lo, _hi in sib}) > 1:return {"GAAP": "GAAP", "ADJUSTED": "adjusted"}.get(v.get("accounting_basis"))return None
1238 unmodified lines1239124012411242124312441238 unmodified lines"GUIDANCE_3": _C({"concept": "REVENUE_GROWTH", "accounting_basis": "ADJUSTED", "low": 0.059, "high": 0.079})}assert C.guidance_basis_label(cat, "GUIDANCE_9") == "GAAP" and C.guidance_basis_label(cat, "GUIDANCE_10") == "adjusted"assert C.guidance_basis_label(cat, "GUIDANCE_2") is None # same figure on both baseslab = RM._method_basis({"multiple_basis": "TRAILING_ADJUSTED", "raw_input_basis": "NTM adjusted EPS (x)"})assert "next-12-month adjusted EPS" in lab and "trailing basis" in lab and not lab.startswith(" trailing")1238 unmodified lines123912401241124212431244124512461247124812491238 unmodified lines"GUIDANCE_3": _C({"concept": "REVENUE_GROWTH", "accounting_basis": "ADJUSTED", "low": 0.059, "high": 0.079})}assert C.guidance_basis_label(cat, "GUIDANCE_9") == "GAAP" and C.guidance_basis_label(cat, "GUIDANCE_10") == "adjusted"assert C.guidance_basis_label(cat, "GUIDANCE_2") is None # same figure on both bases# live f(1790537766): a trigger whose source is an ordinary metric claim (a float), not a guidance rowcat["FORECAST_REVENUE_GROWTH"] = _C(0.068)cat["GUIDANCE_X"] = _C(0.05)assert C.guidance_basis_label(cat, "FORECAST_REVENUE_GROWTH") is None and C.guidance_basis_label(cat, "GUIDANCE_X") is Noneassert C.guidance_basis_label(cat, "GUIDANCE_9") == "GAAP"lab = RM._method_basis({"multiple_basis": "TRAILING_ADJUSTED", "raw_input_basis": "NTM adjusted EPS (x)"})assert "next-12-month adjusted EPS" in lab and "trailing basis" in lab and not lab.startswith(" trailing")
engine/catalog.py+5-2
engine/tests/test_spgi_relations.py+5