Skip to content

Updating minus operator to be order-sensitive#1694

Merged
SFJohnson24 merged 5 commits into
mainfrom
1678-minus-operator-maintain-order
May 12, 2026
Merged

Updating minus operator to be order-sensitive#1694
SFJohnson24 merged 5 commits into
mainfrom
1678-minus-operator-maintain-order

Conversation

@DmitryMK
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated schema has not been merged with markdown descriptions. Please run the "Merge Schema with Markdown Descriptions" workflow to update the merged schema files.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_insensitive to restore legacy behavior.
  • Propagated order_insensitive through OperationParams and RuleProcessor.
  • 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.

Comment thread resources/schema/rule/Operations.md Outdated
Comment thread cdisc_rules_engine/operations/minus.py
Comment thread cdisc_rules_engine/operations/minus.py
Comment thread cdisc_rules_engine/operations/minus.py
Comment thread tests/unit/test_operations/test_minus.py
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated schema has not been merged with markdown descriptions. Please run the "Merge Schema with Markdown Descriptions" workflow to update the merged schema files.

@DmitryMK
Copy link
Copy Markdown
Collaborator Author

After discussion with Sam, the default value of case_insensitive was changed to True.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated schema has not been merged with markdown descriptions. Please run the "Merge Schema with Markdown Descriptions" workflow to update the merged schema files.

@SFJohnson24 SFJohnson24 linked an issue May 12, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated schema has not been merged with markdown descriptions. Please run the "Merge Schema with Markdown Descriptions" workflow to update the merged schema files.

Copy link
Copy Markdown
Collaborator

@SFJohnson24 SFJohnson24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR correctly implements the requested functionality to maintain order with the minus operator using the new bool argument

@SFJohnson24 SFJohnson24 merged commit e13ed6a into main May 12, 2026
5 checks passed
@SFJohnson24 SFJohnson24 deleted the 1678-minus-operator-maintain-order branch May 12, 2026 18:31
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.

Minus operator does not maintain order (uses set)

3 participants