def reset(self):
     # start with all facts
     if self.hyperspaceBindings.withRestrictionBindings:
         facts = self.hyperspaceBindings.withRestrictionBindings[
             -1].yieldedFactsPartition
     else:
         facts = self.sCtx.modelXbrl.nonNilFactsInInstance
     if self.sCtx.formulaOptions.traceVariableFilterWinnowing:
         self.sCtx.modelXbrl.info(
             "sphinx:trace",
             _("Hyperspace %(variable)s binding: start with %(factCount)s facts"
               ),
             sourceFileLine=self.node.sourceFileLine,
             variable=str(self.node),
             factCount=len(facts))
     # filter by hyperspace aspects
     facts = self.filterFacts(facts)
     for fact in facts:
         if fact.isItem:
             self.aspectsDefined |= fact.context.dimAspects(
                 self.sCtx.defaultDimensionAspects)
     self.unQualifiedAspects = self.aspectsDefined - self.aspectsQualified - {
         Aspect.DIMENSIONS
     }
     # implicitly filter by prior uncoveredAspectFacts
     if self.hyperspaceBindings.aspectBoundFacts and not self.isValuesIteration:
         facts = implicitFilter(self.sCtx, self, facts,
                                self.unQualifiedAspects,
                                self.hyperspaceBindings.aspectBoundFacts)
     if self.sCtx.formulaOptions.traceVariableFiltersResult:
         self.sCtx.modelXbrl.info(
             "sphinx:trace",
             _("Hyperspace %(variable)s binding: filters result %(factCount)s facts"
               ),
             sourceFileLine=self.node.sourceFileLine,
             variable=str(self.node),
             factCount=len(facts))
     if self.isWithRestrictionNode:  # if withNode, combine facts into partitions by qualified aspects
         factsPartitions = []
         for fact in facts:
             matched = False
             for partition in factsPartitions:
                 if aspectsMatch(self.sCtx, fact, partition[0],
                                 self.aspectsQualified):
                     partition.append(fact)
                     matched = True
                     break
             if not matched:
                 factsPartitions.append([
                     fact,
                 ])
         self.factIter = iter([set(p)
                               for p in factsPartitions])  # must be sets
         self.yieldedFactsPartition = []
     else:  # just a hyperspaceExpression node
         self.factIter = iter(facts)
     self.yieldedFact = None
     self.fallenBack = False
     self.next()
 def filteredFacts(self, xpCtx, facts):
     aspects = self.aspectsCovered()
     axisAspectValues = dict((aspect, self.aspectValue(xpCtx, aspect))
                             for aspect in aspects)
     fp = FactPrototype(self, axisAspectValues)
     return set(fact
                for fact in facts
                if aspectsMatch(xpCtx, fact, fp, aspects))
 def filteredFacts(self, xpCtx, facts):
     aspects = self.aspectsCovered()
     axisAspectValues = dict((aspect, self.tupleAspectsCovered(aspect))
                             for aspect in aspects
                             if aspect != Aspect.LOCATION)  # location determined by ordCntx, not axis
     fp = FactPrototype(self, axisAspectValues)
     return set(fact
                for fact in facts
                if fact.isTuple and aspectsMatch(xpCtx, fact, fp, aspects))
Beispiel #4
0
 def reset(self):
     # start with all facts
     if self.hyperspaceBindings.withRestrictionBindings:
         facts = self.hyperspaceBindings.withRestrictionBindings[-1].yieldedFactsPartition
     else:
         facts = self.sCtx.modelXbrl.nonNilFactsInInstance
     if self.sCtx.formulaOptions.traceVariableFilterWinnowing:
         self.sCtx.modelXbrl.info("sphinx:trace",
              _("Hyperspace %(variable)s binding: start with %(factCount)s facts"), 
              sourceFileLine=self.node.sourceFileLine, variable=str(self.node), factCount=len(facts))
     # filter by hyperspace aspects
     facts = self.filterFacts(facts)
     for fact in facts:
         if fact.isItem:
             self.aspectsDefined |= fact.context.dimAspects(self.sCtx.defaultDimensionAspects)
     self.unQualifiedAspects = self.aspectsDefined - self.aspectsQualified - {Aspect.DIMENSIONS}
     # implicitly filter by prior uncoveredAspectFacts
     if self.hyperspaceBindings.aspectBoundFacts and not self.isValuesIteration:
         facts = implicitFilter(self.sCtx, self, facts, self.unQualifiedAspects, self.hyperspaceBindings.aspectBoundFacts)
     if self.sCtx.formulaOptions.traceVariableFiltersResult:
         self.sCtx.modelXbrl.info("sphinx:trace",
              _("Hyperspace %(variable)s binding: filters result %(factCount)s facts"), 
              sourceFileLine=self.node.sourceFileLine, variable=str(self.node), factCount=len(facts))
     if self.isWithRestrictionNode: # if withNode, combine facts into partitions by qualified aspects
         factsPartitions = []
         for fact in facts:
             matched = False
             for partition in factsPartitions:
                 if aspectsMatch(self.sCtx, fact, partition[0], self.aspectsQualified):
                     partition.append(fact)
                     matched = True
                     break
             if not matched:
                 factsPartitions.append([fact,])
         self.factIter = iter([set(p) for p in factsPartitions])  # must be sets
         self.yieldedFactsPartition = []
     else: # just a hyperspaceExpression node
         self.factIter = iter(facts)
     self.yieldedFact = None
     self.fallenBack = False
     self.next()