refactoring

This commit is contained in:
frankknoll
2023-01-27 11:14:41 +01:00
parent 4f60b17a55
commit e208727ff7
2 changed files with 7 additions and 6 deletions

View File

@@ -8,13 +8,11 @@ class HistogramDescriptionPersister:
def __init__(self, directory):
self.directory = directory
def saveHistogramDescriptionsForBatchcodes(self, batchcodes, dictByBatchcodeTable):
def saveHistogramDescriptionsForBatchcodes(self, batchcodes, dictByBatchcodeTable, progress):
for count, batchcode in enumerate(batchcodes, start = 1):
histogramDescription = self._getHistogramDescriptionForBatchcode(batchcode, dictByBatchcodeTable)
print(f'{count}/{len(batchcodes)}: saving {batchcode}')
IOUtils.saveDictAsJson(
histogramDescription,
f'{self.directory}/{batchcode}.json')
IOUtils.saveDictAsJson(histogramDescription, f'{self.directory}/{batchcode}.json')
progress(count, len(batchcodes), batchcode)
def _getHistogramDescriptionForBatchcode(self, batchcode, dictByBatchcodeTable):
dictByBatchcodeTableForBatchcode = TableByBatchcodeFilter.filterTableByBatchcode(batchcode, dictByBatchcodeTable)

View File

@@ -189,7 +189,10 @@
"from HistogramDescriptionPersister import HistogramDescriptionPersister\n",
"\n",
"histogramDescriptionPersister = HistogramDescriptionPersister('../docs/data/histograms')\n",
"histogramDescriptionPersister.saveHistogramDescriptionsForBatchcodes(batchcodes[:100], dictByBatchcodeTable)"
"histogramDescriptionPersister.saveHistogramDescriptionsForBatchcodes(\n",
" batchcodes[:100],\n",
" dictByBatchcodeTable,\n",
" progress = lambda count, size, batchcode: print(f'{count}/{size}: {batchcode}'))"
]
},
{