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

Update interface to match assesspy 2.0 #13

Open
wants to merge 8 commits into
base: 1.0.0
Choose a base branch
from

Conversation

jeancochrane
Copy link
Contributor

@jeancochrane jeancochrane commented Dec 12, 2024

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

  • All metrics (COD, PRD, etc.) now have the same inputs (estimate, sale_price) and return the same output (a single number). Previously, some metrics had one input (COD) or different outputs (PRD)
  • The sub-functions of detect_chasing and is_outlier are no longer exported to the user. Instead they can be selected via an argument in their respective functions
  • detect_chasing is renamed to is_sales_chased for consistency with is_outlier
  • Sample datasets are renamed to reflect their respective sources
  • Added the Quintos dataset for testing MKI

Comment on lines +40 to +44
if (method == "quantile") {
out <- quantile_outlier(x, probs = probs)
} else {
out <- iqr_outlier(x, mult = mult)
}
Copy link
Contributor Author

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.

Comment on lines +63 to +73
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]
Copy link
Contributor Author

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.

Comment on lines -87 to -98
#' @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.
Copy link
Contributor Author

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.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (3c0172c) to head (41f0166).
Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@jeancochrane jeancochrane marked this pull request as ready for review December 12, 2024 22:42
@jeancochrane jeancochrane requested a review from a team as a code owner December 12, 2024 22:42
@jeancochrane jeancochrane requested a review from dfsnow December 12, 2024 22:42
@jeancochrane jeancochrane changed the base branch from master to 1.0.0 December 13, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant