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

zincware / MDSuite / 3999396905

pending completion
3999396905

push

github-actions

GitHub
[merge before other PRs] ruff updates (#580)

960 of 1311 branches covered (73.23%)

Branch coverage included in aggregate %.

15 of 15 new or added lines in 11 files covered. (100.0%)

4034 of 4930 relevant lines covered (81.83%)

3.19 hits per line

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

56.67
/mdsuite/visualizer/d2_data_visualization.py
1
"""
2
MDSuite: A Zincwarecode package.
3

4
License
5
-------
6
This program and the accompanying materials are made available under the terms
7
of the Eclipse Public License v2.0 which accompanies this distribution, and is
8
available at https://www.eclipse.org/legal/epl-v20.html
9

10
SPDX-License-Identifier: EPL-2.0
11

12
Copyright Contributors to the Zincwarecode Project.
13

14
Contact Information
15
-------------------
16
email: zincwarecode@gmail.com
17
github: https://github.com/zincware
18
web: https://zincwarecode.com/
19

20
Citation
21
--------
22
If you use this module please cite us with:
23

24
Summary
25
-------
26
"""
27
import pathlib
4✔
28
from typing import List, Union
4✔
29

30
import numpy as np
4✔
31
from bokeh.io import output_file, output_notebook
4✔
32
from bokeh.layouts import gridplot
4✔
33
from bokeh.models import HoverTool
4✔
34
from bokeh.plotting import figure, show
4✔
35

36
from mdsuite.utils import config
4✔
37

38

39
class DataVisualizer2D:
4✔
40
    """Visualizer for two-dimensional data."""
41

42
    def __init__(self, title: str, path: pathlib.Path):
4✔
43
        """
44
        Constructor for the data visualizer.
45

46
        Parameters
47
        ----------
48
        title : str
49
                title of the plot.
50
        path : pathlib.Path
51
                path to the saving directory of the plot
52
        """
53
        if config.jupyter:
4!
54
            output_notebook()
×
55
        else:
56
            output_file(f"{path / title}.html")
4✔
57

58
    def construct_plot(
4✔
59
        self,
60
        x_data: Union[list, np.ndarray],
61
        y_data: Union[list, np.ndarray],
62
        x_label: str,
63
        y_label: str,
64
        title: str,
65
        layouts: List = None,
66
    ) -> figure:
67
        """
68
        Generate a plot.
69

70
        Parameters
71
        ----------
72
        x_data : Union[list, np.ndarray, tf.Tensor]
73
                data to plot along the x axis.
74
        y_data : Union[list, np.ndarray, tf.Tensor]
75
                data to plot along the y axis.
76
        x_label : str
77
                label for the x axis
78
        y_label : str
79
                label of the y axis.
80
        title : str
81
                name of the specific plot.
82

83
        Returns
84
        -------
85
        figure : figure
86
                A bokeh figure object.
87
        """
88
        fig = figure(
×
89
            x_axis_label=x_label,
90
            y_axis_label=y_label,
91
            sizing_mode=config.bokeh_sizing_mode,
92
        )
93
        fig.line(x_data, y_data, legend_label=title)
×
94
        fig.add_tools(HoverTool())
×
95
        if layouts is not None:
×
96
            for item in layouts:
×
97
                fig.add_layout(item)
×
98

99
        return fig
×
100

101
    def grid_show(self, figures: list):
4✔
102
        """
103
        Display a list of figures in a grid.
104

105
        Parameters
106
        ----------
107
        figures : list
108
                A list of figures to display.
109

110
        Returns
111
        -------
112

113
        """
114
        grid = gridplot(figures, ncols=3, sizing_mode="scale_both")
4✔
115
        show(grid)
4✔
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

© 2025 Coveralls, Inc