refactoring
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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}'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user