Skip to content

Commit

Permalink
Merge branch 'main' into feat-preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sasatani authored Dec 7, 2024
2 parents bf3077e + 6e0ca14 commit f0b920b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
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

0 comments on commit f0b920b

Please sign in to comment.