Skip to content

Commit a1a18bc

Browse files
committed
update JSON loading to use ODict and proper file name
1 parent 3917724 commit a1a18bc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

examples/batchCell/src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ def compare(source_file, target_file, source_key=None, target_key=None):
8787
from deepdiff import DeepDiff
8888
with open(source_file, 'r') as fileObj:
8989
if source_file.endswith('.json'):
90-
source = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
90+
source = json.load(fileObj, object_pairs_hook=specs.ODict)
9191
elif source_file.endswith('.pkl'):
9292
source = pickle.load(fileObj)
9393
if source_key: source = source[source_key]
9494

9595
with open(target_file, 'r') as fileObj:
9696
if target_file.endswith('.json'):
97-
target = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
97+
target = json.load(fileObj, object_pairs_hook=specs.ODict)
9898
elif source_file.endswith('.pkl'):
9999
target = pickle.load(fileObj)
100100
if target_key: target = target[target_key]

examples/batchCellMapping/src/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def readBatchData(dataFolder, batchLabel, loadAll=False, saveAll=True, vars=None
1919
print('\nLoading single file with all data...')
2020
filename = '%s/%s/%s_allData.json' % (dataFolder, batchLabel, batchLabel)
2121
with open(filename, 'r') as fileObj:
22-
dataLoad = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
22+
dataLoad = json.load(fileObj, object_pairs_hook=specs.ODict)
2323
params = dataLoad['params']
2424
data = dataLoad['data']
2525
return params, data
@@ -52,10 +52,10 @@ def readBatchData(dataFolder, batchLabel, loadAll=False, saveAll=True, vars=None
5252
# read output file
5353
iCombStr = ''.join([''.join('_'+str(i)) for i in iComb])
5454
simLabel = b['batchLabel']+iCombStr
55-
outFile = b['saveFolder']+'/'+simLabel+'.json'
55+
outFile = b['saveFolder']+'/'+simLabel+'_data.json'
5656
try:
5757
with open(outFile, 'r') as fileObj:
58-
output = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
58+
output = json.load(fileObj, object_pairs_hook=specs.ODict)
5959

6060
# save output file in data dict
6161
data[iCombStr] = {}
@@ -87,14 +87,14 @@ def compare(source_file, target_file, source_key=None, target_key=None):
8787
from deepdiff import DeepDiff
8888
with open(source_file, 'r') as fileObj:
8989
if source_file.endswith('.json'):
90-
source = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
90+
source = json.load(fileObj, object_pairs_hook=specs.ODict)
9191
elif source_file.endswith('.pkl'):
9292
source = pickle.load(fileObj)
9393
if source_key: source = source[source_key]
9494

9595
with open(target_file, 'r') as fileObj:
9696
if target_file.endswith('.json'):
97-
target = json.load(fileObj, object_pairs_hook=specs.OrderedDict)
97+
target = json.load(fileObj, object_pairs_hook=specs.ODict)
9898
elif source_file.endswith('.pkl'):
9999
target = pickle.load(fileObj)
100100
if target_key: target = target[target_key]

0 commit comments

Comments
 (0)