refactoring
This commit is contained in:
@@ -8,13 +8,11 @@ class HistogramDescriptionPersister:
|
|||||||
def __init__(self, directory):
|
def __init__(self, directory):
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
|
|
||||||
def saveHistogramDescriptionsForBatchcodes(self, batchcodes, dictByBatchcodeTable):
|
def saveHistogramDescriptionsForBatchcodes(self, batchcodes, dictByBatchcodeTable, progress):
|
||||||
for count, batchcode in enumerate(batchcodes, start = 1):
|
for count, batchcode in enumerate(batchcodes, start = 1):
|
||||||
histogramDescription = self._getHistogramDescriptionForBatchcode(batchcode, dictByBatchcodeTable)
|
histogramDescription = self._getHistogramDescriptionForBatchcode(batchcode, dictByBatchcodeTable)
|
||||||
print(f'{count}/{len(batchcodes)}: saving {batchcode}')
|
IOUtils.saveDictAsJson(histogramDescription, f'{self.directory}/{batchcode}.json')
|
||||||
IOUtils.saveDictAsJson(
|
progress(count, len(batchcodes), batchcode)
|
||||||
histogramDescription,
|
|
||||||
f'{self.directory}/{batchcode}.json')
|
|
||||||
|
|
||||||
def _getHistogramDescriptionForBatchcode(self, batchcode, dictByBatchcodeTable):
|
def _getHistogramDescriptionForBatchcode(self, batchcode, dictByBatchcodeTable):
|
||||||
dictByBatchcodeTableForBatchcode = TableByBatchcodeFilter.filterTableByBatchcode(batchcode, dictByBatchcodeTable)
|
dictByBatchcodeTableForBatchcode = TableByBatchcodeFilter.filterTableByBatchcode(batchcode, dictByBatchcodeTable)
|
||||||
|
|||||||
@@ -189,7 +189,10 @@
|
|||||||
"from HistogramDescriptionPersister import HistogramDescriptionPersister\n",
|
"from HistogramDescriptionPersister import HistogramDescriptionPersister\n",
|
||||||
"\n",
|
"\n",
|
||||||
"histogramDescriptionPersister = HistogramDescriptionPersister('../docs/data/histograms')\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