Skip to content

Commit

Permalink
Add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Oct 27, 2023
2 parents 12b87bc + 4e5de6f commit 3fc4975
Show file tree
Hide file tree
Showing 13 changed files with 464 additions and 199 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.10.0
hooks:
- id: black
files: ^src/
12 changes: 6 additions & 6 deletions doc/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ How to contribute

TODO: explain with more details

1. Generate the JSON file with probeinterface function (or directly
1. Generate the JSON file with probeinterface (or directly
with another language)
2. Generate an image with `plot_probe`
3. Clone with gin client the `probeinterface_library repo <https://github.com/SpikeInterface/probeinterface_library>`_
4. Put files in the right place.
5. Push to a branch with git client
6. Make a pull request on the gin portal (like a github PR)
2. Generate an image of the probe with the `plot_probe` function in probeinterface
3. Clone the `probeinterface_library repo <https://github.com/SpikeInterface/probeinterface_library>`_
4. Put the JSON file and image into the correct folder or make a new folder (following the format of the repo)
5. Push to one of your branches with a git client
6. Make a pull request to the main repo
13 changes: 13 additions & 0 deletions examples/ex_11_automatic_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@


plt.show()

"""
Available wiring "pathways"
---------------------------
The available pathways can be found in the `probeinterface.wiring <>`_ module.
The following pathways are available:
"""

from probeinterface import get_available_pathways

print(get_available_pathways())
89 changes: 51 additions & 38 deletions src/probeinterface/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@
This module contains useful helper functions for generating probes.
"""

from __future__ import annotations
import numpy as np

from typing import Optional

from .probe import Probe
from .probegroup import ProbeGroup
from .utils import combine_probes


def generate_dummy_probe(elec_shapes="circle"):
def generate_dummy_probe(elec_shapes: str = "circle") -> Probe:
"""
Generate a dummy probe with 3 columns and 32 contacts.
Mainly used for testing and examples.
Parameters
----------
elec_shapes : str, optional
Shape of the electrodes, by default 'circle'
elec_shapes : str, , by default 'circle'
Shape of the electrodes with possibilities of ('circle', 'square', 'rect')
Returns
-------
Expand Down Expand Up @@ -49,7 +51,7 @@ def generate_dummy_probe(elec_shapes="circle"):
return probe


def generate_dummy_probe_group():
def generate_dummy_probe_group() -> ProbeGroup:
"""
Generate a ProbeGroup with 2 probes.
Mainly used for testing and examples.
Expand All @@ -72,10 +74,13 @@ def generate_dummy_probe_group():
return probegroup


def generate_tetrode(r=10):
def generate_tetrode(r: float = 10) -> Probe:
"""
Generate a tetrode Probe.
Parameters
----------
r: float
The distance multiplier for the positions
Returns
-------
probe : Probe
Expand All @@ -89,32 +94,35 @@ def generate_tetrode(r=10):


def generate_multi_columns_probe(
num_columns=3,
num_contact_per_column=10,
xpitch=20,
ypitch=20,
y_shift_per_column=None,
contact_shapes="circle",
contact_shape_params={"radius": 6},
):
num_columns: int = 3,
num_contact_per_column: int = 10,
xpitch: float = 20,
ypitch: float = 20,
y_shift_per_column: Optional[np.array | list] = None,
contact_shapes: str = "circle",
contact_shape_params: dict = {"radius": 6},
) -> Probe:
"""Generate a Probe with several columns.
Parameters
----------
num_columns : int, optional
Number of columns, by default 3
num_contact_per_column : int, optional
Number of contacts per column, by default 10
xpitch : float, optional
Pitch in x direction, by default 20
ypitch : float, optional
Pitch in y direction, by default 20
num_columns : int, by default 3
Number of columns
num_contact_per_column : int, by default 10
Number of contacts per column
xpitch : float, by default 20
Pitch in x direction
ypitch : float, by default 20
Pitch in y direction
y_shift_per_column : array-like, optional
Shift in y direction per column. It needs to have the same length as num_columns, by default None
contact_shapes : str, optional
Shape of the contacts ('circle', 'rect', 'square'), by default 'circle'
contact_shape_params : dict, optional
Parameters for the shape, by default {'radius': 6}
contact_shapes : str, by default 'circle'
Shape of the contacts ('circle', 'rect', 'square')
contact_shape_params : dict, default {'radius': 6}
Parameters for the shape.
For circle: {"radius": float}
For square: {"width": float}
For rectangle: {"width": float, "height": float}
Returns
-------
Expand Down Expand Up @@ -144,19 +152,24 @@ def generate_multi_columns_probe(
return probe


def generate_linear_probe(num_elec=16, ypitch=20, contact_shapes="circle", contact_shape_params={"radius": 6}):
def generate_linear_probe(
num_elec: int = 16, ypitch: float = 20, contact_shapes: str = "circle", contact_shape_params: dict = {"radius": 6}
) -> Probe:
"""Generate a one-column linear probe.
Parameters
----------
num_elec : int, optional
num_elec : int
Number of electrodes, by default 16
ypitch : float, optional
ypitch : float
Pitch in y direction, by default 20
contact_shapes : str, optional
Shape of the contacts ('circle', 'rect', 'square'), by default 'circle'
contact_shape_params : dict, optional
Parameters for the shape, by default {'radius': 6}
contact_shapes : str, default 'circle'
Shape of the contacts ('circle', 'rect', 'square')
contact_shape_params : dict, default {'radius': 6}
Parameters for the shape.
For circle: {"radius": float}
For square: {"width": float}
For rectangle: {"width": float, "height": float}
Returns
-------
Expand All @@ -175,15 +188,15 @@ def generate_linear_probe(num_elec=16, ypitch=20, contact_shapes="circle", conta
return probe


def generate_multi_shank(num_shank=2, shank_pitch=[150, 0], **kargs):
def generate_multi_shank(num_shank: int = 2, shank_pitch: list = [150, 0], **kargs) -> Probe:
"""Generate a multi-shank probe.
Internally, calls generate_multi_columns_probe and combine_probes.
Parameters
----------
num_shank : int, optional
Number of shanks, by default 2
shank_pitch : list, optional
num_shank : int, default 2
Number of shanks
shank_pitch : list, default [150,0]
Distance between shanks, by default [150, 0]
Returns
Expand Down
Loading

0 comments on commit 3fc4975

Please sign in to comment.