New functions for checking multiple sets#1925
New functions for checking multiple sets#1925linuswagner wants to merge 6 commits intousethesource:mainfrom
Conversation
|
Functionality doesn't have tests. Where do the tests go for the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1925 +/- ##
=======================================
Coverage 46% 46%
- Complexity 6725 6736 +11
=======================================
Files 794 794
Lines 65923 65923
Branches 9888 9888
=======================================
+ Hits 30837 30852 +15
+ Misses 32696 32681 -15
Partials 2390 2390 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Very nice additions and necessary to the library. Thanks @linuswagner |
|
Hi @linuswagner, thanks for the nice addition. Could you at at least a few tests to the lang::rascal::tests::library::Set module? |
|
@jurgenvinju I can't find the explanation of it does not actually match pairs, but actually keeps |
Perfect, that's what I was looking for. Thanks! I've decided to make the operations stricter and throw exceptions when the input has not at least 2 elements. Is Rascal generally "better safe than sorry" or "you should better know what you're doing"? |
Cool 👍🏼
I think better safe than sorry. We don't want someone to base their conclusion on something where rascal was just sneakily hiding an error the user made. So if there is no default correct behavior for an input with 1 element, then yeah, throw an exception. |
| public bool isPairwiseDisjoint(wholeInput:list[set[&T]] sets) { | ||
| int sizeSets = size(sets); | ||
| if (sizeSets == 0 || sizeSets == 1) { | ||
| throw IllegalArgument(wholeInput, "Only two or more sets can be pairwise disjoint."); |
There was a problem hiding this comment.
sets == wholeInput, no need to give it two names right?
|
|
||
| test bool testIsPairwiseDisjointIdenticalElements() {return isPairwiseDisjoint([{1}, {1}]) == false;} | ||
| test bool testIsPairwiseDisjointNoOverlap() {return isPairwiseDisjoint([{1,2},{3,4},{5,6}]) == true;} | ||
| test bool testIsPairwiseDisjointOverlap() {return isPairwiseDisjoint([{1,2}, {-4,5}, {1,6,7}]) == false;} No newline at end of file |
There was a problem hiding this comment.
if possible, think of an way to write an random tests. something like:
test bool testRandomPairwiseDisjoint(set[value] a, set[value] b) = (a & b == {}) == isPairwiseDisjoint([a,b]);or even better if you could do it without using the intersection operator.
|
Looking at this to merge the contributions. Currently wrestling with merge conflicts. |
|



Add two functions to
Setlibrary:intersectionto get the intersection of multiple setsisDisjoinedto check if multiple sets are pairwise disjoined