• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

martineberlein / debugging-benchmark / 8171647283

06 Mar 2024 11:57AM UTC coverage: 72.671% (+2.0%) from 70.662%
8171647283

Pull #26

github

web-flow
Merge 08a98172c into f838bc853
Pull Request #26: Release 0.2.0

376 of 465 new or added lines in 22 files covered. (80.86%)

1 existing line in 1 file now uncovered.

1646 of 2265 relevant lines covered (72.67%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/src/debugging_framework/probalistic_grammar_fuzzer.py
1
import random
1✔
2
from typing import List
1✔
3

4
from isla.derivation_tree import DerivationTree
1✔
5

6
from debugging_framework.grammar import exp_probabilities, all_terminals
1✔
7
from debugging_framework.grammar_fuzzer import GrammarFuzzer
1✔
8

9

10
class ProbabilisticGrammarFuzzer(GrammarFuzzer):
1✔
11
    def choose_node_expansion(
1✔
12
        self, node: DerivationTree, children_alternatives: List[List[DerivationTree]]
13
    ) -> int:
14
        (symbol, tree) = node
1✔
15
        expansions = self.grammar[symbol]
1✔
16
        probabilities = exp_probabilities(expansions)
1✔
17

18
        weights: List[float] = []
1✔
19
        for children in children_alternatives:
1✔
20
            expansion = all_terminals((symbol, children))
1✔
21
            children_weight = probabilities[expansion]
1✔
22
            if self.log:
1✔
NEW
23
                print(repr(expansion), "p =", children_weight)
×
24
            weights.append(children_weight)
1✔
25

26
        if sum(weights) == 0:
1✔
27
            # No alternative (probably expanding at minimum cost)
28
            return random.choices(range(len(children_alternatives)))[0]
1✔
29
        else:
30
            return random.choices(range(len(children_alternatives)), weights=weights)[0]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc