Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add configuration for plot functions #288

Merged
merged 58 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c432b28
👌 Change editor config to use 4 spaces as indet size in jupyter noteb…
s-weigand Nov 18, 2023
1b339a3
👌 Make all plot functions available form package root
s-weigand Dec 1, 2023
004fd97
🧹 Add more venv names to .gitignore
s-weigand Apr 5, 2024
fb855de
✨ Add config package and plotconfig module
s-weigand May 24, 2024
46df91e
✨Add PerFunctionPlotConfig
s-weigand May 25, 2024
0282d35
✨ Add PlotConfig
s-weigand May 25, 2024
8a6165e
✨ Add function inspection helper functions
s-weigand May 26, 2024
924810e
✨ Add Config and load helper functions
s-weigand May 26, 2024
a3a6eed
✨ Load config into pyglotaran_extras.CONFIG when pyglotaran_extras is…
s-weigand Jun 7, 2024
7719eb3
✨ Add reset, reload and load methods to config
s-weigand Jun 8, 2024
02e6248
✨ Add use_plot_config decorator to enable config auto use in plot fun…
s-weigand Jun 22, 2024
21bd0ce
✨ Add use_plot_config decorator to all builtin plot functions
s-weigand Jun 22, 2024
bb60b22
✨ Add plot_config_context to override per function plot config
s-weigand Jun 22, 2024
8579e60
♻️ Refactor find_axes into generator to allow for functions with mult…
s-weigand Jun 22, 2024
77dd30b
🧰👌 Typecheck test functions
s-weigand Jun 22, 2024
f74a915
✨ Export CONFIG and PerFunctionPlotConfig from package root
s-weigand Jun 22, 2024
2cbb36d
🧰👌 Configure coverage to work for editable and non editable installation
s-weigand Jun 22, 2024
6c3f2c1
⌨️👌 Improve user facing typing of PerFunctionPlotConfig
s-weigand Jun 22, 2024
2c37f54
🧪🧹 Ensure all figures are closed after each test function
s-weigand Jun 22, 2024
f4929fa
🧹 Fix typo
s-weigand Jun 22, 2024
077f853
👌 Make config loading more resiliant against validation errors
s-weigand Jun 23, 2024
72382f0
✨ Add create_config_schema function
s-weigand Jul 5, 2024
d7e645c
✨ Add config export functionality
s-weigand Jul 5, 2024
f609251
👌 Update config when exporting
s-weigand Jul 5, 2024
357de01
✨ Add rediscover method to config
s-weigand Jul 5, 2024
59a4abc
👌 Make use_plot_config reload the config before using it
s-weigand Jul 5, 2024
86e57db
👌 Refactor use_plot_config to a higher order decorator
s-weigand Jul 5, 2024
014e7ed
👌 Override with correct grammar
jsnel Jul 6, 2024
24f0492
👌Another override with correct grammar
jsnel Jul 6, 2024
17686ec
👌Some long overdue grammar corrections
jsnel Jul 6, 2024
2518a2a
👌Improve test_load_config_on_import_broken_config
jsnel Jul 6, 2024
bc37ac3
🩹 Ensure passing tuple indices trigger xarray.DataArray shorthand syntax
s-weigand Jul 6, 2024
f8db6a1
🧹 Rename config file stem to pygta_config
s-weigand Jul 6, 2024
e52d187
🧹 Serialize PerFunctionPlotConfig in a sparse manner
s-weigand Jul 7, 2024
318506b
👌 Use yaml as config string repr
s-weigand Jul 7, 2024
de2d09e
👌 Add automatic yaml markdown repr for notebooks
s-weigand Jul 7, 2024
95bac4f
👌 Create config schema as part of the docs
s-weigand Jul 7, 2024
3faf933
👌 Export plot_config_context from package root
s-weigand Jul 10, 2024
4cdf6e1
👌 Make axes label renaming agnostric to newlines
s-weigand Jul 10, 2024
847930b
🧹 Replace over_ride with override in test names
s-weigand Jul 11, 2024
5760d2b
👌 Change default folders from '.' to None and use SCRIPT_DIR by default.
s-weigand Jul 19, 2024
00b1689
✨ Add init_project method to CONFIG
s-weigand Jul 19, 2024
cc03767
🧰👌 Always run mypy in py310 mode
s-weigand Jul 20, 2024
86d2e0f
👌 Add yaml reprs to all parts of the config
s-weigand Jul 20, 2024
b6a0e6e
🧹 Remove export from test function name that doesn't test exporing
s-weigand Jul 20, 2024
cfd9b38
🩹 Make importlib_path lookup cross platform
s-weigand Jul 20, 2024
076327c
📚🚇⬆️ Update RTD and sphinx config so notebooks can be used in the docs
s-weigand Jul 20, 2024
aef4682
📚🧰 Use myst-nb instead of nbspinx for mermaid support
s-weigand Jul 20, 2024
6dabcde
🩹 Fix plot_config_context persists when using from import
s-weigand Jul 20, 2024
c3c37eb
👌 Reset source files when config is reset with another config
s-weigand Aug 11, 2024
20ff027
🧰👌 Use pydantic plugin with mypy and update pre-commit
s-weigand Aug 11, 2024
212b48a
🩹 Fix plot config context not being properly reset
s-weigand Aug 24, 2024
60366ae
📚 Config docs
s-weigand Jul 20, 2024
641f85f
🧹 Remove mixing of import and from import of inspect
s-weigand Aug 25, 2024
028c61d
📚 Added comments to explain import structure in run_load_config_on_im…
s-weigand Aug 25, 2024
22a8c71
🚧 Update pinned dependency versions
s-weigand Aug 25, 2024
05bf5a0
🧹 Remove time and spectral labels from plot_pfid
s-weigand Aug 25, 2024
3b6133c
👌 Add __contains__ method to PlotLabelOverrideMap
s-weigand Aug 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.py]
[*.{py,ipynb}]
indent_size = 4

[*.bat]
Expand Down
3 changes: 3 additions & 0 deletions .github/requirements_min.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

cycler==0.10
numpy==1.22
docstring-parser==0.16
matplotlib==3.3
pydantic==2.0.0
pyglotaran==0.7.2
ruamel-yaml==0.18.6
tabulate==0.8.9
xarray==2022.3
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ jobs:
run: |
python -m pip install -U pip wheel
python -m pip install -r requirements_pinned.txt
python -m pip install -U -e ".[test]"
python -m pip install -U ".[test]"

- name: Run tests
run: python -m pytest --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests
run: python -m pytest --nbval --cov=pyglotaran_extras --cov-report term --cov-report xml --cov-config pyproject.toml tests

- name: Codecov Upload
continue-on-error: true
Expand Down Expand Up @@ -140,14 +140,14 @@ jobs:
run: |
python -m pip install -U pip wheel
python -m pip install -r requirements_pinned.txt
python -m pip install -U -e ".[test]"
python -m pip install -U ".[test]"
python -m pip install git+https://github.com/glotaran/pyglotaran

- name: Show installed dependencies
run: pip freeze

- name: Run tests
run: python -m pytest --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests
run: python -m pytest --nbval --cov=pyglotaran_extras --cov-report term --cov-report xml --cov-config pyproject.toml tests

- name: Codecov Upload
continue-on-error: true
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ profile.out
# Distribution / packaging
.Python
env/
venv/
.venv/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -93,10 +95,14 @@ coverage.xml
# Sphinx documentation
docs/_build/
docs/api/
docs/_static
# documents generated by Sphinx.ext.autosummary
docs/source/user_documentation/api/*
# doc figures
docs/source/images/plot
# Files generated by the config docs
pygta_config.schema.json
docs/config/project/subproject/pygta_config.yml

# PyBuilder
target/
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
args: [--in-place, --config, ./pyproject.toml]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.1.3"
rev: "2.2.1"
hooks:
- id: pyproject-fmt

Expand All @@ -46,7 +46,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.7
rev: v0.6.2
hooks:
- id: ruff
name: "ruff sort imports notebooks"
Expand All @@ -72,11 +72,11 @@ repos:
# Linters

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.1
hooks:
- id: mypy
exclude: ^docs
additional_dependencies: [types-tabulate]
additional_dependencies: [types-tabulate, pydantic]

- repo: https://github.com/econchick/interrogate
rev: 1.7.0
Expand All @@ -88,7 +88,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.7
rev: v0.6.2
hooks:
- id: ruff
name: "ruff sort imports"
Expand All @@ -103,20 +103,20 @@ repos:
name: "ruff lint"

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
alias: flake8-docs
args:
- "--select=DOC"
- "--extend-ignore=DOC502"
- "--extend-ignore=DOC502,DOC601,DOC603"
- "--color=always"
- "--require-return-section-when-returning-nothing=False"
- "--allow-init-docstring=True"
- "--skip-checking-short-docstrings=False"
name: "flake8 lint docstrings"
exclude: "^(docs/|tests?/)"
additional_dependencies: [pydoclint==0.3.8]
additional_dependencies: [pydoclint==0.5.6]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
Expand Down
15 changes: 13 additions & 2 deletions .ruff-notebooks.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#:schema https://json.schemastore.org/ruff.json
extend = ".ruff.toml"
extend-ignore = ["D", "E402", "F404"]

[isort]
extend-exclude = [
"docs/conf.py",
]

[lint]
extend-ignore = [
"D",
"E402",
"F404",
"I002", # from __future__ import annotations
]

[lint.isort]
required-imports = []
force-single-line = false
38 changes: 20 additions & 18 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
# Exclude a variety of commonly ignored directories.
extend-exclude = [
"venv",
"docs/conf.py",
"*.ipynb",
]
# Same as Black.
line-length = 99

# Assume Python 3.10.
target-version = "py310"

# Enable using ruff with notebooks
extend-include = ["*.ipynb"]

[lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"C", # mccabe
"F", # pyflakes
"UP", # pyupgrade
"D", # pydocstyle
"N", # pep8-naming
"E", # pycodestyle
"W", # pycodestyle
"C", # mccabe
"F", # pyflakes
"UP", # pyupgrade
"D", # pydocstyle
"N", # pep8-naming
"YTT", # flake8-2020
"BLE", # flake8-blind-except
# "FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"FA", # flake8-future-annotations
"EM", # flake8-errmsg
"I", # isort (activates import sorting for formatter)
"FA", # flake8-future-annotations
"EM", # flake8-errmsg
"I", # isort (activates import sorting for formatter)
"ISC", # flake8-implicit-str-concat
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PT", # flake8-pytest-style
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"ERA", # eradicate
"PD", # pandas-vet
"PD", # pandas-vet
"PGH", # pygrep-hooks
"NPY", # NumPy-specific
"RUF", # Ruff-specific
Expand All @@ -60,13 +58,17 @@ ignore = [
# Covered by formatter
"ISC001",
]
external = ["DOC"]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.per-file-ignores]
"tests/*" = ["ARG001"]

"tests/data/*" = ["INP", "D"]
"tests/data/config/run_load_config_on_import.py" = [
"I002", # from __future__ import annotations
]
[lint.isort]
required-imports = ["from __future__ import annotations"]
known-first-party = ["pyglotaran_extras"]
Expand Down
20 changes: 16 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
# relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#

from pathlib import Path
import pyglotaran_extras

HERE = Path(__file__).parent

pyglotaran_extras.create_config_schema(HERE/"_static")

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

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -33,23 +37,31 @@
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"myst_parser",
"myst_nb",
'sphinxcontrib.mermaid',
"sphinx_copybutton",
"sphinx_rtd_theme",
]

myst_fence_as_directive = ["mermaid"]


autoclass_content = "both"
autosummary_generate = True
add_module_names = False
autodoc_member_order = "bysource"

autodoc_pydantic_model_show_config_summary=False
autodoc_pydantic_model_show_validator_summary=False


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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = [".rst", ".md"]
source_suffix = {'.rst': 'restructuredtext', '.md': 'restructuredtext'}
# source_suffix = '.rst'
linkcheck_ignore = [
r"https://github\.com/glotaran/pyglotaran-extras/actions",
Expand Down Expand Up @@ -111,7 +123,7 @@
# 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 HTMLHelp output ---------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions docs/config/project/fs_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plotting:
general:
axis_label_override:
time: "Time (fs)"
18 changes: 18 additions & 0 deletions docs/config/project/pygta_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plotting:
general:
default_args_override:
linlog: true
use_svd_number: true
linthresh: 2
axis_label_override:
time: "Time (ps)"
spectral: "Wavelength (nm)"
data_left_singular_vectors: ""
data_singular_values: "Singular Value (a.u.)"
data_right_singular_vectors: ""
plot_svd:
default_args_override:
use_svd_number: false
plot_overview:
default_args_override:
show_data: True
Loading
Loading