Skip to content

Conversation

@Ykabrit
Copy link
Contributor

@Ykabrit Ykabrit commented Feb 3, 2026

Added a new attribute to BackgroundKnowledge, called forbidden_within_tiers, which is a set of integers that correspond to tiers within which we forbid all orientation.
Methods forbid_within_tier and allow_within_tier are added to add and remove tiers from the new set. By default, the set is empty and orientation within tiers is allowed, as it was before.
The method is_forbidden is slightly modified in order to check if the two nodes are from the same tier, and if it is the case and the tier is in forbidden_within_tiers, return True.

Tested using the PC algorithm.

…nowledge

Signed-off-by: Ykabrit <ykabrit@yanibou.fr>
@kunwuz
Copy link
Collaborator

kunwuz commented Feb 8, 2026

Thanks a lot for the great contribution! To also let others benefit from this more directly, could you please add a test case in https://github.com/py-why/causal-learn/blob/main/tests/TestBackgroundKnowledge.py to showcase the usage?

Signed-off-by: Ykabrit <ykabrit@yanibou.fr>
…kgroundKnowledge

Signed-off-by: Ykabrit <ykabrit@yanibou.fr>
@Ykabrit
Copy link
Contributor Author

Ykabrit commented Feb 10, 2026

I added a test case as you requested, test_forbid_allow_within_tier.
Also, I noticed an error in my previous commit, added a fix.

@kunwuz kunwuz self-requested a review February 10, 2026 17:07
@kunwuz kunwuz merged commit 282d352 into py-why:main Feb 10, 2026
2 checks passed
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.

2 participants