Skip to content

Commit

Permalink
Use black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFehring committed Feb 19, 2024
1 parent 960dcd3 commit 28ecb76
Show file tree
Hide file tree
Showing 24 changed files with 590 additions and 542 deletions.
52 changes: 20 additions & 32 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,55 @@
from recommonmark.parser import CommonMarkParser

# -- Project information -----------------------------------------------------
project = 'PyExperimenter'
copyright = '2022, Tanja Tornede, Alexander Tornede, Lukas Fehring, Lukas Gehring, Helena Graf, Jonas Hanselle, Felix Mohr, Marcel Wever'
author = 'Tanja Tornede, Alexander Tornede, Lukas Fehring, Lukas Gehring, Helena Graf, Jonas Hanselle, Felix Mohr, Marcel Wever'
project = "PyExperimenter"
copyright = "2022, Tanja Tornede, Alexander Tornede, Lukas Fehring, Lukas Gehring, Helena Graf, Jonas Hanselle, Felix Mohr, Marcel Wever"
author = "Tanja Tornede, Alexander Tornede, Lukas Fehring, Lukas Gehring, Helena Graf, Jonas Hanselle, Felix Mohr, Marcel Wever"

# The full version, including alpha/beta/rc tags
release = '1.0'
release = "1.0"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'autoapi.extension',
'recommonmark',
'nbsphinx',
'sphinx_gallery.load_style'
]
extensions = ["sphinx.ext.autodoc", "autoapi.extension", "recommonmark", "nbsphinx", "sphinx_gallery.load_style"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
'_build',
'Thumbs.db',
'.DS_Store'
]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
"logo_only": False,
"display_version": True,
"prev_next_buttons_location": "bottom",
"style_external_links": True,
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [
'_static'
]
html_static_path = ["_static"]

# -- Options for API ---------------------------------------------------------
autoapi_dirs = ['../../py_experimenter']
autoapi_dirs = ["../../py_experimenter"]
18 changes: 8 additions & 10 deletions py_experimenter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class Cfg(ABC):

@abstractclassmethod
def extract_config(self, **kwargs) -> "Cfg":
"""
Expand Down Expand Up @@ -108,7 +107,7 @@ def extract_config(config: OmegaConf, logger: logging.Logger) -> Tuple["Database
)

@staticmethod
def _extract_keyfields(keyfields: DictConfig, logger) -> Dict[str, Keyfield]:
def _extract_keyfields(keyfields: DictConfig, logger) -> Dict[str, Keyfield]:
extracted_keyfields = dict()
for keyfield_name, keyfield_content in keyfields.items():
keyfield_type, values = DatabaseCfg._extract_value_range(keyfield_name, keyfield_content, logger)
Expand All @@ -120,22 +119,21 @@ def _extract_keyfields(keyfields: DictConfig, logger) -> Dict[str, Keyfield]:

logger.info(f"Found {len(keyfields)} keyfields")
return extracted_keyfields

@staticmethod
def _extract_value_range(keyfield_name:str, keyfield_content: DictConfig, logger) -> Tuple[str, List[Union[int, str, bool, Any]]]:
def _extract_value_range(keyfield_name: str, keyfield_content: DictConfig, logger) -> Tuple[str, List[Union[int, str, bool, Any]]]:
keyfield_type = keyfield_content["type"]
if "values" not in keyfield_content:
logger.warning(f"No values given for keyfield {keyfield_name}")
return keyfield_type, None



if isinstance(keyfield_content["values"], ListConfig):
values = list(keyfield_content["values"])

elif isinstance(keyfield_content["values"], DictConfig):
if "start" not in keyfield_content["values"] or "stop" not in keyfield_content["values"]:
raise InvalidColumnError(f"Invalid keyfield values: {keyfield_name}")

start = keyfield_content["values"]["start"]
stop = keyfield_content["values"]["stop"]
if "step" in keyfield_content["values"]:
Expand All @@ -151,10 +149,10 @@ def _extract_resultfields(table_config: OmegaConf, logger) -> Dict[str, str]:
logger.warning("No resultfields given")
resultfields = dict()
return False, resultfields

if not isinstance(table_config["resultfields"], DictConfig):
raise InvalidColumnError(f"Invalid resultfields: {table_config['resultfields']}")

resultfields = dict(table_config["resultfields"])

if "result_timestamps" in table_config:
Expand Down
Loading

0 comments on commit 28ecb76

Please sign in to comment.