Skip to content

Conversation

@paddyroddy
Copy link
Member

@paddyroddy paddyroddy commented Dec 5, 2025

Description

Following the work in #865, this PR further excludes imports. Currently, glass/cosmology.py reports 0% coverage, which isn't true. This is a bit overkill but should make the percentage more clear.

Have also adjusted the @overload decorator to avoid the case of, i.e. @overloaded,

Closes: #866

Checks

  • Is your code passing linting?
  • Is your code passing tests?
  • Have you added additional tests (if required)?
  • Have you modified/extended the documentation (if required)?
  • Have you added a one-liner changelog entry above (if required)?

@paddyroddy paddyroddy self-assigned this Dec 5, 2025
@paddyroddy paddyroddy added enhancement New feature or request infrastructure Project infrastructure: dev tools, packaging, etc. testing Work is related to testing labels Dec 5, 2025
@paddyroddy paddyroddy requested a review from connoraird December 5, 2025 15:13
Copy link
Contributor

@connoraird connoraird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coverage seems to have decreased. Does this not remove the lines from the percentage?

@paddyroddy
Copy link
Member Author

The coverage seems to have decreased. Does this not remove the lines from the percentage?

So I think it does remove the lines, but the percentage will depend on what was covered. Here, the only noticeable decrease is for the benchmarks. If we look at, e.g. glass/algorithm.py. I think it makes sense that the coverage has "decreased".

Before 8.25%

Manually counting I see:

  • 4 import lines covered
  • 4 non-import lines covered
  • 75 lines not covered

8/75=10.7% 🤔 might be something to do with branch coverage

coverage before change

After 4.3%

Manually counting I see:

  • 0 import lines covered
  • 4 non-import lines covered
  • 75 lines not covered

4/75=5.3% 🤔 might be something to do with branch coverage

coverage after change

@connoraird
Copy link
Contributor

@paddyroddy I'm not sure I follow. So the import lines are still counted in the total number of lines to be covered. Does that mean this ignore is purely for the highlighting in the coveralls UI?

@paddyroddy
Copy link
Member Author

@paddyroddy I'm not sure I follow. So the import lines are still counted in the total number of lines to be covered. Does that mean this ignore is purely for the highlighting in the coveralls UI?

Pretty much. The lines aren't counted in those to be covered. It's the same reason we're doing it for the others

@paddyroddy
Copy link
Member Author

See #279

@paddyroddy
Copy link
Member Author

So the import lines are still counted in the total number of lines to be covered.

This statement is incorrect

@paddyroddy
Copy link
Member Author

@connoraird failing with this. Think we shouldn't do import tests.conftest directly 🤔

image

@connoraird
Copy link
Contributor

@connoraird failing with this. Think we shouldn't do import tests.conftest directly 🤔

Weird, I originally had just import conftest but I noticed we were using import test.conftest in the type checking block.

@paddyroddy
Copy link
Member Author

Weird, I originally had just import conftest but I noticed we were using import test.conftest in the type checking block.

We're doing from tests.conftest, subtly different

@paddyroddy
Copy link
Member Author

Actually the issue is that it's not in a type checking block. You aren't really meant to import from test files

@paddyroddy
Copy link
Member Author

Related pytest-dev/pytest#349

@connoraird
Copy link
Contributor

Actually the issue is that it's not in a type checking block. You aren't really meant to import from test files

Yeah I know you're not supposed to but I didn't know how else to use xp_available_backends in the definition of the parameter like I do here.

import conftest
...
@pytest.mark.stable
@pytest.mark.parametrize(
    "xp",
    [
        xp
        for name, xp in conftest.xp_available_backends.items()
        if name != "jax.numpy"
    ],
)
def test_displacement(
    benchmark: BenchmarkFixture,
    urng: UnifiedGenerator,
    xp: ModuleType,  # noqa: ARG001
) -> None:
    """Benchmark for glass.displacement with all backends, but jax."""
    _benchmark_displacement(benchmark, urng)

@connoraird
Copy link
Contributor

@paddyroddy Unless I make a fixture which excludes jax from xp?

@paddyroddy
Copy link
Member Author

@paddyroddy Unless I make a fixture which excludes jax from xp?

Let's do that. I'll revert the changes in this PR and wait until we've got that in.

@paddyroddy
Copy link
Member Author

Broken due to changes in #864. Will merge as the fixes are unrelated.

@paddyroddy paddyroddy merged commit bdac5e6 into main Dec 9, 2025
12 of 13 checks passed
@paddyroddy paddyroddy deleted the paddy/issue-866 branch December 9, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request infrastructure Project infrastructure: dev tools, packaging, etc. testing Work is related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude imports from coverage report

3 participants