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

DIGNEA / DIGNEApy / 14240561723

03 Apr 2025 10:16AM UTC coverage: 86.041% (-1.3%) from 87.305%
14240561723

push

github

amarrerod
✨ Introduces to_df/to_series functionality

41 of 83 new or added lines in 14 files covered. (49.4%)

1 existing line in 1 file now uncovered.

1917 of 2228 relevant lines covered (86.04%)

1.72 hits per line

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

0.0
/digneapy/utils/save_data.py
1
#!/usr/bin/env python
2
# -*-coding:utf-8 -*-
NEW
3
"""
×
4
@File    :   save_data.py
5
@Time    :   2025/04/03 10:02:16
6
@Author  :   Alejandro Marrero
7
@Version :   1.0
8
@Contact :   amarrerd@ull.edu.es
9
@License :   (C)Copyright 2025, Alejandro Marrero
10
@Desc    :   None
11
"""
12

NEW
13
from typing import Optional
×
NEW
14
from collections.abc import Sequence
×
NEW
15
from digneapy.generators import GenResult
×
NEW
16
import pandas as pd
×
17

18

NEW
19
def save_instances(
×
20
    filename: str,
21
    result: GenResult,
22
    solvers_names: Optional[Sequence[str]],
23
    features_names: Optional[Sequence[str]],
24
    vars_names: Optional[Sequence[str]],
25
) -> pd.DataFrame:
26
    """Saves the results from a Generator into a pd.DataFrame and writes it to a CSV file.
27

28
    Args:
29
        filename (str): filename to store the results.
30
        result (GenResult): Results from a Generator object.
31
        solvers_names (Optional[Sequence[str]]): Optionally you can provide the names of the solvers used in the experiment. Default to solver_i.
32
        features_names (Optional[Sequence[str]]): Optionally you can provide the names of the features of the instances if used. Default to fi.
33
        vars_names (Optional[Sequence[str]]): Optionally you can provide custom names for the variables of the instances. Default to vi.
34

35
    Returns:
36
        pd.DataFrame: _description_
37
    """
NEW
38
    df = pd.DataFrame(
×
39
        list(
40
            i.to_series(
41
                variables_names=vars_names,
42
                features_names=features_names,
43
                score_names=solvers_names,
44
            )
45
            for i in result.instances
46
        )
47
    )
NEW
48
    df.insert(0, "target", result.target)
×
NEW
49
    df.to_csv(filename, index=False)
×
NEW
50
    return df
×
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