Skip to content

Commit ea331ae

Browse files
committed
Validation: minor tweaks
1 parent 73016c3 commit ea331ae

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

tests/compare_outputs.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class MISSING:
2121
VERBOSE = False
2222
ENABLE_XML = False
2323
ENABLE_CSV = True
24+
ENABLE_JSON = True
2425

2526
KNOWN_COM_DIFF = set([
2627
# On official COM, uninitialized values for CalcCurrent, AllocFactors
@@ -343,15 +344,20 @@ def compare_all(self):
343344
try:
344345
fB = zipB.open(fn, 'r')
345346
fA = zipA.open(fn, 'r')
346-
print(fn)
347347
except KeyError:
348-
print('MISSING:', fn)
348+
if not fn.endswith('GISCoords.dss'):
349+
print('MISSING:', fn)
350+
349351
continue
350352
except BadZipFile:
351353
print('BAD:', fn)
352354
continue
353355

354-
if fn.endswith('.json'):
356+
if ENABLE_JSON and fn.endswith('.json'):
357+
if not ENABLE_JSON:
358+
continue
359+
360+
print(fn)
355361
dataA = json.load(fA)
356362
dataB = json.load(fB)
357363

@@ -367,7 +373,12 @@ def compare_all(self):
367373
print("COMPARE ERROR:", fn)
368374
raise
369375

370-
elif ENABLE_XML and fn.endswith('.xml'):
376+
elif fn.endswith('.xml'):
377+
if not ENABLE_XML:
378+
continue
379+
380+
print(fn)
381+
371382
# Comparing the XMLs is tricky, but this initial implementation
372383
# can still be useful. For DSS C-API 0.13.0, we manually checked.
373384
# One issue is that the maintenance of ExportCIMXML.pas is not
@@ -391,7 +402,12 @@ def compare_all(self):
391402

392403
print(type(d))
393404

394-
elif ENABLE_CSV and fn.endswith('.csv'):
405+
elif fn.endswith('.csv'):
406+
if not ENABLE_CSV:
407+
continue
408+
409+
print(fn)
410+
395411
# The CSVs from OpenDSS can havbe some weird header, and we need to compare
396412
# the lowercase data to simplify things.
397413
textA = fA.read().decode().lower()
@@ -400,6 +416,9 @@ def compare_all(self):
400416
df_a = pd.read_csv(sfA)
401417
df_b = pd.read_csv(sfB)
402418

419+
df_a.columns = [x.strip() for x in df_a.columns]
420+
df_b.columns = [x.strip() for x in df_b.columns]
421+
403422
try:
404423
pd.testing.assert_frame_equal(df_a, df_b, atol=tol, rtol=tol)
405424
except:

tests/save_outputs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ def get_archive_fn(live_fn):
366366

367367
t0_global = perf_counter()
368368
total_runtime = 0.0
369-
with ZipFile(os.path.join(original_working_dir, f'results{suffix}.zip'), mode='a', compression=ZIP_DEFLATED) as zip_out:
369+
zip_fn = f'results{suffix}.zip'
370+
with ZipFile(os.path.join(original_working_dir, zip_fn), mode='a', compression=ZIP_DEFLATED) as zip_out:
370371
for fn in test_filenames + cimxml_test_filenames:
371372
org_fn = fn
372373
fixed_fn = fn if not fn.startswith('L!') else fn[2:]
@@ -431,4 +432,5 @@ def get_archive_fn(live_fn):
431432

432433
print(perf_counter() - t0_global, 'seconds')
433434
print(total_runtime, 'seconds (runtime only)')
435+
print(zip_fn)
434436

0 commit comments

Comments
 (0)