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

Test docs #75

Merged
merged 7 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/docs-test.yml
Original file line number Diff line number Diff line change
@@ -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@v4
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: make html
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
26 changes: 15 additions & 11 deletions miniscope_io/plots/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@

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:
def buffer_count(headers: pd.DataFrame, ax: "plt.Axes") -> "plt.Axes":
"""
Plot number of buffers by time
"""
Expand All @@ -35,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
"""
Expand All @@ -45,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
"""
Expand All @@ -60,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
"""
Expand All @@ -73,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` )

Expand Down Expand Up @@ -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]
Expand All @@ -147,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()
Expand Down
Loading