py-xbrl icon indicating copy to clipboard operation
py-xbrl copied to clipboard

Equals method for all fact classes

Open manusimidt opened this issue 1 year ago • 1 comments

Add an eq() method to all fact classes to test for equality

manusimidt avatar Mar 19 '23 08:03 manusimidt

If it helps, I've been using the code below to check for fact equality:

def fact_compare(first:AbstractFact, second:AbstractFact):
    if type(first) != type(second):
        return False

    if first.value != second.value:
        return False

    if first.xml_id != second.xml_id:
        return False

    if first.footnote != second.footnote:
        return False

    if isinstance(first, NumericFact):
        first:NumericFact = first
        second:NumericFact = second

        if first.decimals != second.decimals:
            return False

        if first.unit != second.unit:
            return False

    else:
        first:TextFact = first
        second:TextFact = second

    if not context_compare(first.context, second.context):
        return False

    if not concept_compare(first.concept, second.concept):
        return False

    return True

stkerr avatar Mar 19 '23 19:03 stkerr