(self, src, ancReload, maxTime)
| 48 | |
| 49 | # Preparation functions |
| 50 | def prepareRpsData(self, src, ancReload, maxTime): |
| 51 | # Time is none means that time parameter has to be ignored, |
| 52 | # we do not need cache for that |
| 53 | if maxTime is None: |
| 54 | return True |
| 55 | self._generateInternalForm(src=src, ancReload=ancReload, maxTime=maxTime) |
| 56 | fitCache = self._data[src.item.ID][ancReload] |
| 57 | # Final cache has been generated already, don't do anything |
| 58 | if 'finalRps' in fitCache: |
| 59 | return |
| 60 | # Convert cache from segments with assigned values into points |
| 61 | # which are located at times when rps value changes |
| 62 | pointCache = {} |
| 63 | for key, rpsList in fitCache['internalRps'].items(): |
| 64 | pointData = pointCache[key] = {} |
| 65 | prevRps = None |
| 66 | prevTimeEnd = None |
| 67 | for timeStart, timeEnd, rps in rpsList: |
| 68 | # First item |
| 69 | if not pointData: |
| 70 | pointData[timeStart] = rps |
| 71 | # Gap between items |
| 72 | elif floatUnerr(prevTimeEnd) < floatUnerr(timeStart): |
| 73 | pointData[prevTimeEnd] = RRTypes(0, 0, 0, 0) |
| 74 | pointData[timeStart] = rps |
| 75 | # Changed value |
| 76 | elif rps != prevRps: |
| 77 | pointData[timeStart] = rps |
| 78 | prevRps = rps |
| 79 | prevTimeEnd = timeEnd |
| 80 | # We have data in another form, do not need old one any longer |
| 81 | del fitCache['internalRps'] |
| 82 | changesByTime = {} |
| 83 | for key, rpsMap in pointCache.items(): |
| 84 | for time in rpsMap: |
| 85 | changesByTime.setdefault(time, []).append(key) |
| 86 | # Here we convert cache to following format: |
| 87 | # {time: {key: rps} |
| 88 | finalRpsCache = fitCache['finalRps'] = {} |
| 89 | timeRpsData = {} |
| 90 | for time in sorted(changesByTime): |
| 91 | timeRpsData = copy(timeRpsData) |
| 92 | for key in changesByTime[time]: |
| 93 | timeRpsData[key] = pointCache[key][time] |
| 94 | finalRpsCache[time] = timeRpsData |
| 95 | |
| 96 | def prepareRepAmountData(self, src, ancReload, maxTime): |
| 97 | # Time is none means that time parameter has to be ignored, |
no test coverage detected