From fb95e645b6eec78785efbf628cd2d19657b7586d Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:17:01 -0800 Subject: [PATCH 1/6] test docs --- .github/workflows/docs-test.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/docs-test.yml diff --git a/.github/workflows/docs-test.yml b/.github/workflows/docs-test.yml new file mode 100644 index 00000000..2964c10a --- /dev/null +++ b/.github/workflows/docs-test.yml @@ -0,0 +1,33 @@ +name: Build and test documentation + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + test_docs: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up python + uses: actions/setup-python@v3 + with: + python-version: "3.12" + cache: "pip" + + - name: Install dependencies + run: pip install -e .[docs] pytest-md + + - name: Build docs + working-directory: docs + env: + SPHINXOPTS: "-W --keep-going" + run: pdm run make html From 418867977c1b12d063b70c23d8fe1add3ac39773 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:18:31 -0800 Subject: [PATCH 2/6] test docs --- .github/workflows/docs-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-test.yml b/.github/workflows/docs-test.yml index 2964c10a..e0597222 100644 --- a/.github/workflows/docs-test.yml +++ b/.github/workflows/docs-test.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v3 - name: Set up python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.12" cache: "pip" From bbfffe73a12c7859daf58405b62c7c47494e9b36 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:19:26 -0800 Subject: [PATCH 3/6] test docs --- .github/workflows/docs-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-test.yml b/.github/workflows/docs-test.yml index e0597222..29205726 100644 --- a/.github/workflows/docs-test.yml +++ b/.github/workflows/docs-test.yml @@ -30,4 +30,4 @@ jobs: working-directory: docs env: SPHINXOPTS: "-W --keep-going" - run: pdm run make html + run: make html From fb7407f48cc0e94dcd62752dbd9e1f5354e34552 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:24:51 -0800 Subject: [PATCH 4/6] don't require matplotlib to import --- miniscope_io/plots/headers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/miniscope_io/plots/headers.py b/miniscope_io/plots/headers.py index 71ba1d28..edfbf01a 100644 --- a/miniscope_io/plots/headers.py +++ b/miniscope_io/plots/headers.py @@ -14,11 +14,8 @@ try: import matplotlib.pyplot as plt -except ImportError as e: - raise ImportError( - "matplotlib is not a required dependency of miniscope-io, " - "install it with the miniscope-io[plot] extra or manually in your environment :)" - ) from e +except ImportError: + plt = None def buffer_count(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: @@ -132,6 +129,13 @@ def __init__( history_length (int): Number of headers to plot update_ms (int): milliseconds between each plot update """ + global plt + if plt is None: + raise ModuleNotFoundError( + "matplotlib is not a required dependency of miniscope-io, to use it, " + "install it manually or install miniscope-io with `pip install miniscope-io[plot]`" + ) + # If a single string is provided, convert it to a list with one element if isinstance(header_keys, str): header_keys = [header_keys] From 7a783382a63db97f2fcecdd8dbc6793db70ba54a Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:28:00 -0800 Subject: [PATCH 5/6] don't require matplotlib to import --- miniscope_io/plots/headers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/miniscope_io/plots/headers.py b/miniscope_io/plots/headers.py index edfbf01a..12b49e85 100644 --- a/miniscope_io/plots/headers.py +++ b/miniscope_io/plots/headers.py @@ -18,7 +18,7 @@ plt = None -def buffer_count(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: +def buffer_count(headers: pd.DataFrame, ax: "plt.Axes") -> "plt.Axes": """ Plot number of buffers by time """ @@ -32,7 +32,7 @@ def buffer_count(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: return ax -def dropped_buffers(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: +def dropped_buffers(headers: pd.DataFrame, ax: "plt.Axes") -> "plt.Axes": """ Plot number of buffers by time """ @@ -42,7 +42,7 @@ def dropped_buffers(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: return ax -def timestamps(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: +def timestamps(headers: pd.DataFrame, ax: "plt.Axes") -> "plt.Axes": """ Plot frame number against time """ @@ -57,7 +57,7 @@ def timestamps(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: return ax -def battery_voltage(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: +def battery_voltage(headers: pd.DataFrame, ax: "plt.Axes") -> "plt.Axes": """ Plot battery voltage against time """ @@ -70,7 +70,7 @@ def battery_voltage(headers: pd.DataFrame, ax: plt.Axes) -> plt.Axes: def plot_headers( headers: pd.DataFrame, size: Optional[Tuple[int, int]] = None -) -> (plt.Figure, plt.Axes): +) -> ("plt.Figure", "plt.Axes"): """ Plot the headers (generated from :meth:`.Frame.to_df` ) @@ -151,7 +151,7 @@ def __init__( def _init_plot( self, - ) -> tuple[plt.Figure, dict[str, plt.Axes], dict[str, plt.Line2D]]: + ) -> tuple["plt.Figure", dict[str, "plt.Axes"], dict[str, "plt.Line2D"]]: # initialize matplotlib plt.ion() From 692fc36a91e673d34f5cc6042ee7366f154d9171 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 11 Nov 2024 20:32:22 -0800 Subject: [PATCH 6/6] rm static path --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 17452239..e808027d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,7 +41,6 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = "furo" -html_static_path = ["_static"] intersphinx_mapping = { "python": ("https://docs.python.org/3", None),