Updating minus operator to be order-sensitive#1694
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the minus rule operation so that, by default, subtraction respects the order of items in subtract, with a new order_insensitive flag to retain the prior “set difference” behavior when needed (e.g., for ADaM use cases).
Changes:
- Implemented an order-sensitive minus behavior (default) and added
order_insensitiveto restore legacy behavior. - Propagated
order_insensitivethroughOperationParamsandRuleProcessor. - Updated unit tests and rule schema/docs to describe and validate the new option.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
cdisc_rules_engine/operations/minus.py |
Adds order-sensitive/insensitive difference helpers and switches default minus behavior. |
cdisc_rules_engine/models/operation_params.py |
Adds order_insensitive: bool parameter (default False). |
cdisc_rules_engine/utilities/rule_processor.py |
Plumbs order_insensitive from rule definitions into OperationParams. |
resources/schema/rule/Operations.json |
Allows order_insensitive as a valid operation property in the schema. |
resources/schema/rule/Operations.md |
Documents new default semantics and the order_insensitive option with an example. |
resources/schema/rule/check_parameter.md |
Documents order_insensitive parameter behavior for minus. |
tests/unit/test_operations/test_minus.py |
Updates helper tests and adds operation-level tests for order-sensitive and order-insensitive modes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
After discussion with Sam, the default value of case_insensitive was changed to True. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #1678
Updated the default behavior to take order of the subtract into consideration. So ["A", "B", "C"] minus ["C", "B"] is ["A", "B"].
I have added optional property for minus operator: order_insensitive which defaults to false. When it is set to true, it will allow minus to act as in the original version and just perform a set difference. I think we will need it for ADaM where there is no strict order of variables.
@SFJohnson24 I have a question about Operations.json. For each operator there is only a list of required properties specified, but properties themselves are not described alongside the operation. In Operator.json I can see that options are described as I would expect them. So for example value_is_reference is a permissible option for distinct operation, but it is not described as a property for distinct in Operations.json.