-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update interface to match assesspy 2.0 #13
base: 1.0.0
Are you sure you want to change the base?
Conversation
if (method == "quantile") { | ||
out <- quantile_outlier(x, probs = probs) | ||
} else { | ||
out <- iqr_outlier(x, mult = mult) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ifelse
here since we're returning a vector, in which case ifelse
coerces the return value to the same shape as the test.
is.vector(x) | ||
is.numeric(x) | ||
!is.nan(x) | ||
length(x) > 2 | ||
all(is.finite(x) | is.na(x)) # All values are finite OR are NA | ||
is.numeric(gap) | ||
gap > 0 | ||
gap < 1 | ||
is.vector(bounds) | ||
is.numeric(bounds) | ||
bounds[2] > bounds[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving all of the input checks up here from the sub-functions.
#' @describeIn detect_chasing CDF gap method for detecting sales chasing. | ||
#' @param bounds Ratio boundaries to use for detection. The CDF method will | ||
#' return TRUE if the CDF gap exceeding the threshold is found within these | ||
#' bounds. The distribution method will calculate the percentage of ratios | ||
#' within these bounds for the actual data and an ideal normal distribution. | ||
#' Expanding these bounds increases likelihood of detection. | ||
#' @param cdf_gap Ratios that have bunched up around a particular value | ||
#' (typically 1) will appear as a flat spot on the CDF. The longer this flat | ||
#' spot, the worse the potential sales chasing. This variable indicates the | ||
#' length of that flat spot and can be thought of as the proportion of ratios | ||
#' that have the same value. For example, 0.03 means that 3% of ratios share | ||
#' the same value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped the docs for these functions, since they're no longer public.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #13 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 187 195 +8
=========================================
+ Hits 187 195 +8 ☔ View full report in Codecov by Sentry. |
This PR is the companion to ccao-data/assesspy#24, updating the interface to match the latest version of the Python package.
Warning
This is a breaking refactor. It significantly changes the API of some functions and deprecates others. As such, this PR is intended to target a new major version release (1.0.0).
Breaking changes
estimate
,sale_price
) and return the same output (a single number). Previously, some metrics had one input (COD) or different outputs (PRD)detect_chasing
andis_outlier
are no longer exported to the user. Instead they can be selected via an argument in their respective functionsdetect_chasing
is renamed tois_sales_chased
for consistency withis_outlier