Skip to content

Update interface to match assesspy 2.0#13

Open
jeancochrane wants to merge 8 commits into1.0.0from
jeancochrane/update-R-interface-for-1.0.0
Open

Update interface to match assesspy 2.0#13
jeancochrane wants to merge 8 commits into1.0.0from
jeancochrane/update-R-interface-for-1.0.0

Conversation

@jeancochrane
Copy link
Copy Markdown
Member

@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 thread R/outliers.R
Comment on lines +40 to +44
if (method == "quantile") {
out <- quantile_outlier(x, probs = probs)
} else {
out <- iqr_outlier(x, mult = mult)
}
Copy link
Copy Markdown
Member 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 thread R/sales_chasing.R
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
Copy Markdown
Member 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 thread R/sales_chasing.R
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
Copy Markdown
Member 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 12, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (1.0.0@82b3cca). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             1.0.0       #13   +/-   ##
=========================================
  Coverage         ?   100.00%           
=========================================
  Files            ?         5           
  Lines            ?       195           
  Branches         ?         0           
=========================================
  Hits             ?       195           
  Misses           ?         0           
  Partials         ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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
@dfsnow dfsnow removed their request for review March 2, 2025 19:18
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