Permalink
Browse files

ARELLE-66: dimension member state testing looping when same concept

appears in same ELR in directed cycle.  Tricky fix requires tracking
ELR of ordinary dim-mbr-tree because same member may appear in multiple
ELRs with different usability states without causing a cycle!
  • Loading branch information...
1 parent c711551 commit 6c612bd1b3ff3c9ef83be2ad6d73d324ad6abe19 @hefischer hefischer committed Apr 3, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 arelle/ValidateXbrlDimensions.py
@@ -420,22 +420,23 @@ def dimensionMemberState(val, dimConcept, memConcept, domELR):
dimensionMemberStates[key] = state
return state
-def memberStateInDomain(val, memConcept, rels, ELR, fromConcepts=None):
+def memberStateInDomain(val, memConcept, rels, ELR, toConceptELRs=None):
foundState = NOT_FOUND
- if fromConcepts is None:
- fromConcepts = set()
+ if toConceptELRs is None:
+ toConceptELRs = defaultdict(set)
for rel in rels:
toConcept = rel.toModelObject
if toConcept == memConcept:
foundState = max(foundState,
MEMBER_USABLE if rel.isUsable else MEMBER_NOT_USABLE)
- if toConcept not in fromConcepts:
- fromConcepts.add(toConcept)
toELR = (rel.targetRole or ELR)
- domMbrRels = val.modelXbrl.relationshipSet(XbrlConst.domainMember, toELR).fromModelObject(toConcept)
- foundState = max(foundState,
- memberStateInDomain(val, memConcept, domMbrRels, toELR, fromConcepts))
- fromConcepts.discard(toConcept)
+ toELRs = toConceptELRs[toConcept]
+ if toELR not in toELRs: # looping if it's already there in a visited ELR
+ toELRs.add(toELR)
+ domMbrRels = val.modelXbrl.relationshipSet(XbrlConst.domainMember, toELR).fromModelObject(toConcept)
+ foundState = max(foundState,
+ memberStateInDomain(val, memConcept, domMbrRels, toELR, toConceptELRs))
+ toELRs.discard(toELR)
return foundState
''' removed because no valid way to check one isolated dimension for validity without full set of others

0 comments on commit 6c612bd

Please sign in to comment.