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

cylammarco / WDPhotTools / 20978266610

14 Jan 2026 12:54AM UTC coverage: 95.519% (-0.6%) from 96.096%
20978266610

push

github

web-flow
v0.0.13 (#49)

* handling numpy 2 (#47)

* Compat: use numpy generic types for v1/v2 (np.floating/np.integer) in src; no stylistic changes

* Allow NumPy 2 in install: relax to >=1.23,<3; update README to state v1+v2 support

* updated array handling

* removed test output figure

* updated setup.cfg to include numpy2

* use asarray

* use np.where

* use where instead of argwhere; wrapped interpolator outputs with np.asarray(...).itme() or reshape(-1)[0].

* pack values in correct array shape for atmosphere interpolator

* Tests/coverage improvements (#48)

* tests: increase coverage and add edge-case tests across modules

* added more tests

* final fixes to the minimisation function and the interpolation functions. updated example scripts and tests.

* updated test

* avoid extrapolation in both ct and rbf interpolator for the atmosphere model

* fixed extrapolation issue

299 of 337 new or added lines in 11 files covered. (88.72%)

4 existing lines in 3 files now uncovered.

3389 of 3548 relevant lines covered (95.52%)

1.91 hits per line

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

97.56
/test/test_datafiles_coverage.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3

4
import os
2✔
5
import re
2✔
6
import numpy as np
2✔
7
import pytest
2✔
8
from importlib.resources import files
2✔
9

10

11
def _repo_path(*parts):
2✔
12
    return str(files("WDPhotTools").joinpath(*parts))
2✔
13

14

15
def _load_numeric_table(path, delimiter=None):
2✔
16
    num_re = re.compile(r"[+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?")
2✔
17
    rows = []
2✔
18
    with open(path, "r", encoding="utf-8", errors="ignore") as f:
2✔
19
        for i in f:
2✔
20
            if re.match(r"^[=\-\s]*$", i):
2✔
21
                continue
2✔
22
            nums = [float(m.group(0)) for m in num_re.finditer(i)]
2✔
23
            if len(nums) >= 2:
2✔
24
                rows.append(nums)
2✔
25
    if not rows:
2✔
NEW
26
        raise AssertionError(f"No numeric lines detected in {path}")
×
27
    lengths = {}
2✔
28
    for r in rows:
2✔
29
        lengths[len(r)] = lengths.get(len(r), 0) + 1
2✔
30
    target_len = max(lengths, key=lengths.get)
2✔
31
    filtered = [r[:target_len] for r in rows if len(r) >= target_len]
2✔
32
    return np.array(filtered, dtype=float)
2✔
33

34

35
@pytest.mark.parametrize(
2✔
36
    "fname",
37
    [
38
        # ms_lifetime CSVs
39
        os.path.join(_repo_path("ms_lifetime"), f)
40
        for f in os.listdir(_repo_path("ms_lifetime"))
41
        if f.endswith(".csv")
42
    ],
43
)
44
def test_ms_lifetime_csv_loads(fname):
2✔
45
    dt = np.loadtxt(fname, delimiter=",")
2✔
46
    assert dt.ndim == 2 and dt.shape[0] > 0 and dt.shape[1] > 0
2✔
47

48

49
@pytest.mark.parametrize(
2✔
50
    "fname",
51
    [
52
        # extinction CSVs
53
        os.path.join(_repo_path("extinction"), f)
54
        for f in os.listdir(_repo_path("extinction"))
55
        if f.endswith(".csv")
56
    ],
57
)
58
def test_extinction_csv_loads(fname):
2✔
59
    dt = np.loadtxt(fname, delimiter=",")
2✔
60
    assert dt.ndim == 2 and dt.shape[0] > 0 and dt.shape[1] > 0
2✔
61

62

63
@pytest.mark.parametrize(
2✔
64
    "fname",
65
    [
66
        # wd_cooling bedard20 txts
67
        os.path.join(_repo_path("wd_cooling", "bedard20"), f)
68
        for f in os.listdir(_repo_path("wd_cooling", "bedard20"))
69
        if f.endswith(".txt")
70
    ],
71
)
72
def test_wd_cooling_bedard20_txt_loads(fname):
2✔
73
    dt = _load_numeric_table(fname)
2✔
74
    assert dt.ndim == 2 and dt.shape[0] > 0 and dt.shape[1] > 0
2✔
75

76

77
@pytest.mark.parametrize(
2✔
78
    "fname",
79
    [
80
        # wd_photometry tables
81
        os.path.join(_repo_path("wd_photometry"), f)
82
        for f in os.listdir(_repo_path("wd_photometry"))
83
        if f.endswith(".txt")
84
    ],
85
)
86
def test_wd_photometry_txt_loads(fname):
2✔
87
    dt = _load_numeric_table(fname)
2✔
88
    assert dt.ndim == 2 and dt.shape[0] > 0 and dt.shape[1] > 0
2✔
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