コード例 #1
0
class LayerSpec:
    label: str = ""
    dataset: str = ""
    variable: str = ""
    active: List[int] = field(default_factory=list)
    color_spec: colors.ColorSpec = colors.ColorSpec()
    colorbar: dict = field(default_factory=dict)

    def __post_init__(self):
        if isinstance(self.color_spec, dict):
            self.color_spec = colors.ColorSpec(**self.color_spec)
コード例 #2
0
 def __post_init__(self):
     if isinstance(self.color_spec, dict):
         self.color_spec = colors.ColorSpec(**self.color_spec)
コード例 #3
0
import unittest.mock
from unittest.mock import Mock
import pytest
from forest import colors, redux
import forest.db.control
import bokeh.models
import numpy as np


@pytest.mark.parametrize(
    "given,expect",
    [
        pytest.param({}, colors.ColorSpec()),
        pytest.param(
            {"limits": {"origin": "user", "user": {"high": 100, "low": 42}}},
            colors.ColorSpec(low=42, high=100),
        ),
        pytest.param(
            {
                "limits": {
                    "origin": "column_data_source",
                    "user": {"high": 100, "low": 42},
                    "column_data_source": {"high": 5, "low": 4},
                }
            },
            colors.ColorSpec(low=4, high=5),
        ),
        pytest.param(
            {
                "name": "Accent",
                "number": 3,