New functions for checking multiple sets#1925
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;} |
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. |
…r-range-ignores Made messages related to ignore more precise.
…n-test-errors2 Fix errors in integration tests 2
…ry-spelling Fix doc tags, spelling errors and typos in library documentation
* Add missing modules in Prelude documentation. * Remove trailing spaces.
…oid NPEs and other crashes
…pendency-check-return-statement Fix/missing dependency check return statement
* Update to typepal-0.16.7 * Fix changed error message
…om-loc Add overload for summary from TPL location
…ong module names
fixed usethesource#2747 and a number of other error scenarios like wrong module names
- This is needed for proper execution order - This is rather coarse solution. Maybe move this to cases for type parameters?
…pendency-check-typed-var-pattern Fix/missing dependency check typed var pattern
|
945817e to
115d649
Compare



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