Skip to content

Commit

Permalink
Merge pull request #1843 from SEED-platform/dimensionality-hotfix
Browse files Browse the repository at this point in the history
Data Quality Dimensionality Hotfix
  • Loading branch information
nllong committed Mar 11, 2019
2 parents 8dcdf7e + 148471a commit 6e81cfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion seed/models/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def format_pint_violation(rule, source_value):
formatted_min = formatted_max = None
incoming_data_units = source_value.units
rule_units = ureg(rule.units)
rule_value = source_value.to(rule_units)
if rule_units.dimensionless:
rule_value = source_value
else:
rule_value = source_value.to(rule_units)

pretty_source_units = pretty_units(source_value)
pretty_rule_units = pretty_units(rule_value)
Expand Down Expand Up @@ -641,6 +644,10 @@ def _check(self, rules, row):

if hasattr(row, rule.field):
value = getattr(row, rule.field)
# TODO cleanup after the cleaner is better able to handle fields with units on import
# If the rule doesn't specify units only consider the value for the purposes of numerical comparison
if isinstance(value, ureg.Quantity) and rule.units == '':
value = value.magnitude
elif rule.field in row.extra_data:
value = row.extra_data[rule.field]
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ angular.module('BE.seed.controller.data_quality_admin', [])
];

$scope.units = [
{id: null, label: ''},
{id: '', label: ''},
{id: 'ft**2', label: 'square feet'},
{id: 'm**2', label: 'square metres'},
{id: 'kBtu/ft**2/year', label: 'kBtu/sq. ft./year'},
Expand Down

0 comments on commit 6e81cfb

Please sign in to comment.