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

DIGNEA / DIGNEApy / 16416951177

21 Jul 2025 12:27PM UTC coverage: 90.447% (-0.6%) from 91.09%
16416951177

push

github

amarrerod
📌 Pins fcmaes to 1.6.11

2064 of 2282 relevant lines covered (90.45%)

1.81 hits per line

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

31.25
/digneapy/utils/save_data.py
1
#!/usr/bin/env python
2
# -*-coding:utf-8 -*-
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

13
from collections.abc import Sequence
2✔
14
from typing import Literal, Optional
2✔
15

16
import pandas as pd
2✔
17

18
from digneapy.generators import GenResult
2✔
19

20

21
def save_results_to_files(
2✔
22
    filename_pattern: str,
23
    result: GenResult,
24
    solvers_names: Optional[Sequence[str]],
25
    features_names: Optional[Sequence[str]],
26
    vars_names: Optional[Sequence[str]],
27
    format: Literal["csv", "parquet"] = "parquet",
28
):
29
    """Saves the results of the generation to CSV files.
30
    Args:
31
        filename_pattern (str): Pattern for the filenames.
32
        result (GenResult): Result of the generation.
33
        solvers_names (Sequence[str]): Names of the solvers.
34
        features_names (Sequence[str]): Names of the features.
35
        vars_names (Sequence[str]): Names of the variables.
36
        format (Literal[str] = "csv" or "parquet"): Format to store the resulting instances file.
37
            Parquet is the most efficient for large datasets.
38
    """
39
    df = pd.DataFrame(
×
40
        [
41
            i.to_series(
42
                variables_names=vars_names,
43
                features_names=features_names,
44
                score_names=solvers_names,
45
            )
46
            for i in result.instances
47
        ]
48
    )
49
    if not df.empty:
×
50
        df.insert(0, "target", result.target)
×
51
        print(df.head())
×
52
    if format == "csv":
×
53
        df.to_csv(f"{filename_pattern}_instances.csv", index=False)
×
54
    elif format == "parquet":
×
55
        df.to_parquet(f"{filename_pattern}_instances.parquet", index=False)
×
56

57
    result.history.to_df().to_csv(f"{filename_pattern}_history.csv", index=False)
×
58
    if result.metrics is not None:
×
59
        result.metrics.to_csv(f"{filename_pattern}_archive_metrics.csv")
×
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