markrogoyski / itertools-php

PHP Iteration Tools Library
MIT License
140 stars 11 forks source link

Test cases for 1-partial intersections of multisets #20

Closed Smoren closed 1 year ago

Smoren commented 1 year ago

Set::intersectionPartial() test cases added for multisets with $minIntersectionCount = 1.

Explanation of the behavior:

For any N when M = 1 we have a union of sets or multisets.

image

Some examples of multiset unions from this article:

I've added test cases for this examples and some more complicated cases. They all work predictably.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 3994320702

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Totals Coverage Status
Change from base Build 3993592557: 0.0%
Covered Lines: 463
Relevant Lines: 464

💛 - Coveralls
markrogoyski commented 1 year ago

Thanks for the explanation and examples. From what I understand, a union of a multiset is really taking the item from the set that has the max cardinality, rather than "adding" them all together. Your examples show the same thing. Thanks.

Smoren commented 1 year ago

OK. I'm glad that we have come to a common perception of this functionality.

You can merge this PR if you want to add the tests included in it.

Smoren commented 1 year ago

BTW, I was very surprised that the concept of partial intersection was not defined in math. I consulted with mathematician friends and decided to write an article on this topic.

Thank you for the inspiration!

Smoren commented 1 year ago

Hi @markrogoyski,

FYI: I've created a new repository with explanation and examples of the partial intersection.