Skip to content

Commit

Permalink
Add renderer for expect_column_values_to_be_decreasing
Browse files Browse the repository at this point in the history
  • Loading branch information
roblim committed Jul 16, 2019
1 parent 03cafb0 commit 4624a5a
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,37 @@ def expect_column_values_to_be_increasing(cls, expectation, styling=None, includ
"styling": styling,
}]

# TODO: test parse_strings_as_datetimes
@classmethod
def expect_column_values_to_be_decreasing(cls, expectation, styling=None, include_column_name=True):
params = substitute_none_for_missing(
expectation["kwargs"],
["column", "strictly", "mostly", "parse_strings_as_datetimes"]
)

if params.get("strictly"):
template_str = "values must be strictly less than previous values"
else:
template_str = "values must be less than or equal to previous values"

if params.get("mostly"):
params["mostly_pct"] = "%.1f" % (params["mostly"] * 100,)
template_str += ", at least $mostly_pct % of the time."
else:
template_str += "."

if params.get("parse_strings_as_datetimes"):
template_str += " Values should be parsed as datetimes."

if include_column_name:
template_str = "$column " + template_str

return [{
"template": template_str,
"params": params,
"styling": styling,
}]

@classmethod
def expect_column_values_to_be_unique(cls, expectation, styling=None, include_column_name=True):
params = substitute_none_for_missing(
Expand Down

0 comments on commit 4624a5a

Please sign in to comment.