gs-quant icon indicating copy to clipboard operation
gs-quant copied to clipboard

RiskMeasure - how to check for equality : RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate returns False

Open AlexanderJHall opened this issue 5 years ago • 1 comments

Describe the bug RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate Returns False. Arguably this should return True.

What is the correct way to check for RiskMeasure equality?

For example: RiskMeasure.from_dict(IRFwdRate.as_dict()).measure_type == IRFwdRate.measure_type returns True, but this feels a little clunky.

I ask as I'd like to write code like: if risk_measure in (IRFwdRate, IRSpotRate, etc, etc):

where risk_measure has been created by RiskMeasure.from_dict(some_measure.as_dict()).

To Reproduce from gs_quant.risk import IRFwdRate from gs_quant.target.risk import RiskMeasure RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate

Returns False.

Expected behavior RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate to return True.

OR please explain how I should compare RiskMeasure types

AlexanderJHall avatar Jul 08 '20 08:07 AlexanderJHall

@AnastasiyaB Any thoughts on this? RiskMeasure.from_dict(IRFwdRate.as_dict()) != IRFwdRate feels a bit icky...

AlexanderJHall avatar Jul 22 '20 21:07 AlexanderJHall