question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Insufficient combination when filter function is specified?

See original GitHub issue

Hello, thank you for providing a great library! I tried to use filter function to cut invalid combination, but it seems generated combinations are insufficient.

# Generate combinations of every supported Python + NumPy version combination.

from allpairspy import AllPairs

numpy = ['1.9', '1.10', '1.11', '1.12', '1.13', '1.14']
python = ['2.7', '3.4', '3.5', '3.6']

def _validate(numpy, python):
    valid = []
    if numpy == '1.9':
        valid = ['2.7', '3.4']
    elif numpy == '1.10':
        valid = ['2.7', '3.4']
    elif numpy == '1.11':
        valid = ['2.7', '3.4', '3.5']
    elif numpy == '1.12':
        valid = ['2.7', '3.4', '3.5', '3.6']
    elif numpy == '1.13':
        valid = ['2.7', '3.4', '3.5', '3.6']
    elif numpy == '1.14':
        valid = ['2.7', '3.4', '3.5', '3.6']
    return python in valid


def _filter_func(row):
    if len(row) == 2:
        stat = _validate(*row)
        #print('Valid? ', row, ' -> ', stat)
        return stat
    return True


if __name__ == '__main__':
    for i, pairs in enumerate(AllPairs([numpy, python], filter_func=_filter_func)):
        print(i, ':', pairs)

I got:

0 : ['1.9', '2.7']
1 : ['1.10', '2.7']
2 : ['1.11', '2.7']
3 : ['1.12', '2.7']
4 : ['1.13', '2.7']
5 : ['1.14', '2.7']
6 : ['1.14', '3.4']
7 : ['1.13', '3.4']
8 : ['1.12', '3.4']
9 : ['1.11', '3.4']
10 : ['1.10', '3.4']
11 : ['1.9', '3.4']

It seems Python 3.5/3.6 variations are totally ignored. Am I missing something? Any suggestions are welcome. Thanks in advance!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thombashicommented, Apr 10, 2018

@kmaehashi Thank you for your comment. That is unexpected behavior. I will check into it.

0reactions
ashfaq92commented, Dec 1, 2022

Code:

parameters = OrderedDict(
    {"x1": [True, False],
     "x2": [True, False]})


def constraints(row):
    n = len(row)
    if n > 1:
        if row[0] is False and row[1] is False:
            return False
    return True


print("PAIRWISE:")
res = AllPairs(parameters, filter_func=constraints, n=2)

Desired Output:

0 Pairs(x1=True, x2=True)
1 Pairs(x1=False, x2=True)
2 Pairs(x1=True, x2=False)

Actual Output:

0 Pairs(x1=True, x2=True)
1 Pairs(x1=False, x2=True)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel FILTER function with formula examples - Ablebits
The FILTER function in Excel is used to filter a range of data based on the criteria that you specify. The function belongs...
Read more >
Filter by using advanced criteria - Microsoft Support
If the data you want to filter requires complex criteria (such as Type = "Produce" OR Salesperson = "Davolio"), you can use the...
Read more >
Python's filter(): Extract Values From Iterables
Combining filter () With Other Functional Tools ... With filter() , you can apply a filtering function to an iterable and produce a...
Read more >
Elegant way to combine multiple filtering functions in Haskell
Applicative (liftA2) -- given f1 etc. filtered = filter (f1 <&&> f2 ... It's unfortunate that you need to unwrap the combined predicates ......
Read more >
Filtration Efficiency - an overview | ScienceDirect Topics
Filtration efficiency is usually stated in terms of the percentage of particles of a certain size that would be stopped and retained by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found