Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouped cartesian product results support #3

Open
sekgobela-kevin opened this issue Oct 30, 2022 · 2 comments
Open

Grouped cartesian product results support #3

sekgobela-kevin opened this issue Oct 30, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@sekgobela-kevin
Copy link
Owner

Instead of having result of cartesian poduct as a very large iterator.
The result can be grouped by another iterable items which wil result in 3D iterable instead of 2D iterable.

prodius.product([0,1], [2,3]) -> [(0, 2), [0, 3), (1,2), (1,3)]

# First iterable was used for grouping
product.product_group([0,1], [2,3]) ->[[(0, 2), (0, 3)], [(1,2), (1,3)]] 

# Same thing be archieved as
product.product_group([2,3], group=[0,1]) ->[[(0, 2), (0, 3)], [(1,2), (1,3)]] 
@sekgobela-kevin sekgobela-kevin added the enhancement New feature or request label Oct 30, 2022
@sekgobela-kevin
Copy link
Owner Author

Forcetable already has basic implementation of it.
But can be easily done using prodius.product() but individually on items of iterable with items for grouping.

product_group = []
for item in group:
  item_product = prodius.product([item], iterables)
  product_group.append(item_product)

@sekgobela-kevin
Copy link
Owner Author

There is no need to split functionality into its own function but let it be in form of argument.

product.product([2,3], group=[0,1]) ->[[(0, 2), (0, 3)], [(1,2), (1,3)]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant