Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple QA demo #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions qa/qa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import csv
import os
import sys

input_dir = ''
if len(sys.argv) > 1:
input_dir = sys.argv[1]

classifications = {}
with open(os.path.join(input_dir, 'Classification.csv'), newline='', encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
classifications[row['Classification_Mnemonic']] = row

categories = {}
with open(os.path.join(input_dir, 'Category.csv'), newline='', encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
classification_mnemonic = row['Classification_Mnemonic']
if classification_mnemonic not in categories:
categories[classification_mnemonic] = []
categories[classification_mnemonic].append(row['Category_Code'])

for mnemonic, classification in classifications.items():
expected_num_cats = int(classifications[mnemonic]['Number_Of_Category_Items'])
if not expected_num_cats:
continue

cats = categories.get(mnemonic, [])
if len(cats) != len(set(cats)):
duplicate_codes = [c for c in cats if cats.count(c) > 1]
print(f'Duplicate categories {duplicate_codes} found for classification {mnemonic}')

if expected_num_cats and expected_num_cats != len(cats):
print(f'Expected {expected_num_cats} categories for classification {mnemonic} but found {len(cats)}')