Skip to content

Commit

Permalink
Do not exclude any partial branches from coverage report (#208)
Browse files Browse the repository at this point in the history
Even if the branches aren't able to be coverage by their nature, it
makes for a more honest coverage score.
  • Loading branch information
caleb531 authored Feb 11, 2024
1 parent cc41406 commit f4c521b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ increased from 79 characters to 120 characters.
2. Whether you are introducing a bug fix or a new feature, you *must* add tests
to verify that your code additions function correctly and break nothing else.

3. Please run `coverage run -m nose2 && coverage report` to ensure that code
coverage remains close to 100%.
3. Please run `coverage run -m nose2 && coverage report` and ensure that your
changes are covered.

4. If you are adding a new feature or changing behavior, I ask that you please
update the README appropriately with the relevant documentation.
Expand Down
2 changes: 1 addition & 1 deletion automata/fa/dfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def random_word(self, k: int, *, seed: Optional[int] = None) -> str:
total = self._count_cache[remaining][state]
choice = rng.randint(0, total - 1)
transition = self.transitions[state]
for symbol, next_state in transition.items(): # pragma: no branch
for symbol, next_state in transition.items():
next_state_count = self._count_cache[remaining - 1][next_state]
if choice < next_state_count:
result.append(symbol)
Expand Down
12 changes: 6 additions & 6 deletions automata/fa/gnfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def from_dfa(cls: Type[Self], target_dfa: dfa.DFA) -> Self:
for state in target_dfa.final_states:
new_gnfa_transitions[state][new_final_state] = ""

for state in gnfa_states - {new_final_state}: # pragma: no branch
if gnfa_states - new_gnfa_transitions[state].keys(): # pragma: no branch
for state in gnfa_states - {new_final_state}:
if gnfa_states - new_gnfa_transitions[state].keys():
for leftover_state in gnfa_states - new_gnfa_transitions[state].keys():
if leftover_state is not new_initial_state:
new_gnfa_transitions[state][leftover_state] = None
Expand Down Expand Up @@ -217,8 +217,8 @@ def from_nfa(cls: Type[Self], target_nfa: nfa.NFA) -> Self:
for state in target_nfa.final_states:
new_gnfa_transitions[state][new_final_state] = ""

for state in gnfa_states - {new_final_state}: # pragma: no branch
if gnfa_states - new_gnfa_transitions[state].keys(): # pragma: no branch
for state in gnfa_states - {new_final_state}:
if gnfa_states - new_gnfa_transitions[state].keys():
for leftover_state in gnfa_states - new_gnfa_transitions[state].keys():
if leftover_state is not new_initial_state:
new_gnfa_transitions[state][leftover_state] = None
Expand Down Expand Up @@ -252,7 +252,7 @@ def _validate_transition_end_states(
) -> None:
"""Raise an error if transition end states are invalid or missing"""
if start_state == self.final_state:
if len(paths) != 0: # pragma: no branch
if len(paths) != 0:
raise exceptions.InvalidStateError(
"No transitions should be defined for "
"final state {}".format(start_state)
Expand All @@ -275,7 +275,7 @@ def _validate_transition_end_states(
start_state, str(self.states - paths.keys() - {self.initial_state})
)
)
for end_state in paths.keys(): # pragma: no branch
for end_state in paths.keys():
if end_state not in self.states:
raise exceptions.InvalidStateError(
"end state {} for transition on {} is "
Expand Down
2 changes: 1 addition & 1 deletion automata/tm/tape.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def move(self, direction: TMDirectionT) -> Self:
new_position += 1
elif direction == "N":
pass
elif direction == "L": # pragma: no branch
elif direction == "L":
new_position -= 1
# Make sure that the cursor doesn't run off the end of the tape.
if new_position == -1:
Expand Down

0 comments on commit f4c521b

Please sign in to comment.