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

deepset-ai / haystack / 14331243843

08 Apr 2025 10:28AM UTC coverage: 90.128% (+0.04%) from 90.085%
14331243843

Pull #9182

github

web-flow
Merge dfe96cfb7 into 2665d048b
Pull Request #9182: enhancement: Add attributes to PipelineRuntimeError

10664 of 11832 relevant lines covered (90.13%)

0.9 hits per line

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

63.64
haystack/utils/misc.py
1
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
2
#
3
# SPDX-License-Identifier: Apache-2.0
4

5
from typing import List, Union
1✔
6

7
from numpy import exp
1✔
8

9

10
def expand_page_range(page_range: List[Union[str, int]]) -> List[int]:
1✔
11
    """
12
    Takes a list of page numbers and ranges and expands them into a list of page numbers.
13

14
    For example, given a page_range=['1-3', '5', '8', '10-12'] the function will return [1, 2, 3, 5, 8, 10, 11, 12]
15

16
    :param page_range: List of page numbers and ranges
17
    :returns:
18
        An expanded list of page integers
19

20
    """
21
    expanded_page_range = []
1✔
22

23
    for page in page_range:
1✔
24
        if isinstance(page, int):
1✔
25
            # check if it's a range wrongly passed as an integer expression
26
            if "-" in str(page):
×
27
                msg = "range must be a string in the format 'start-end'"
×
28
                raise ValueError(f"Invalid page range: {page} - {msg}")
×
29
            expanded_page_range.append(page)
×
30

31
        elif isinstance(page, str) and page.isdigit():
1✔
32
            expanded_page_range.append(int(page))
×
33

34
        elif isinstance(page, str) and "-" in page:
1✔
35
            start, end = page.split("-")
1✔
36
            expanded_page_range.extend(range(int(start), int(end) + 1))
1✔
37

38
        else:
39
            msg = "range must be a string in the format 'start-end' or an integer"
×
40
            raise ValueError(f"Invalid page range: {page} - {msg}")
×
41

42
    if not expanded_page_range:
1✔
43
        raise ValueError("No valid page numbers or ranges found in the input list")
×
44

45
    return expanded_page_range
1✔
46

47

48
def expit(x) -> float:
1✔
49
    """
50
    Compute logistic sigmoid function. Maps input values to a range between 0 and 1
51

52
    :param x: input value. Can be a scalar or a numpy array.
53
    """
54
    return 1 / (1 + exp(-x))
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