Skip to content

Commit 87dbbce

Browse files
a-faclaude
andcommitted
Fix incorrect API usages in documentation code examples
- SpikeParser: replace nonexistent params (threshold_start, min_width) with valid ones (prominence, distance, width) - _ignored: rewrite section to note it's private, recommend contextlib.suppress - to_json: fix positional arg to keyword (filename=), add note that from_json is unimplemented - IVCurveParser: change keyword arg to positional Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 944b3fb commit 87dbbce

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

docs/_build/doc_example_fixes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Documentation Code Example Fixes
2+
3+
Fixes for incorrect API usages found in documentation code examples.
4+
5+
| File | Line | Before | After | Reason |
6+
|------|------|--------|-------|--------|
7+
| `docs/api/core.rst` | 199 | `SpikeParser(threshold_start=0.15, threshold_end=0.15, min_width=10, max_width=10000)` | `SpikeParser(prominence=0.15, distance=100, width=(10, 10000))` | Parameters `threshold_start`, `threshold_end`, `min_width`, `max_width` don't exist in SpikeParser. Actual params: `height`, `threshold`, `distance`, `prominence`, `width`, etc. |
8+
| `docs/api/core.rst` | 227 | `from ionique.core import ignored` | Replaced section: notes `_ignored` is internal, recommends `contextlib.suppress` | Function is `_ignored` (private). Not importable as `ignored`. Replaced with standard library equivalent. |
9+
| `docs/parsers_guide.rst` | 128 | `parser.to_json("my_parser.json")` | `parser.to_json(filename="my_parser.json")` | `to_json()` takes `filename` as keyword arg, not positional. |
10+
| `docs/parsers_guide.rst` | 132 | `restored = Parser.from_json(json_str)` | Removed; added note that `from_json` is not yet implemented | `from_json` returns `None` (stub). Showing it as working is misleading. |
11+
| `docs/parsers/other_parsers.rst` | 202 | `IVCurveParser(voltage=voltage_array)` | `IVCurveParser(voltage_array)` | `voltage` is a positional argument in the constructor. |

docs/api/core.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,9 @@ Use the ``parse()`` method to subdivide segments using parser objects:
197197
198198
# Create a parser
199199
parser = SpikeParser(
200-
threshold_start=0.15,
201-
threshold_end=0.15,
202-
min_width=10,
203-
max_width=10000
200+
prominence=0.15,
201+
distance=100,
202+
width=(10, 10000)
204203
)
205204
206205
# Parse events within each voltage step
@@ -217,27 +216,24 @@ Use the ``parse()`` method to subdivide segments using parser objects:
217216
Utilities
218217
---------
219218

220-
ignored
221-
^^^^^^^
219+
_ignored (internal)
220+
^^^^^^^^^^^^^^^^^^^
222221

223-
A context manager to suppress specific exceptions (replaces try/except/pass):
222+
``_ignored`` is a private context manager used internally to suppress specific
223+
exceptions. It is not part of the public API.
224224

225-
.. code-block:: python
225+
For your own code, use the equivalent pattern from the standard library:
226226

227-
from ionique.core import ignored
227+
.. code-block:: python
228228
229-
# Instead of:
230-
try:
231-
value = some_dict["missing_key"]
232-
except KeyError:
233-
pass
229+
from contextlib import suppress
234230
235-
# Use:
236-
with ignored(KeyError):
231+
# Suppress a specific exception
232+
with suppress(KeyError):
237233
value = some_dict["missing_key"]
238234
239-
# Can ignore multiple exception types
240-
with ignored(KeyError, AttributeError):
235+
# Suppress multiple exception types
236+
with suppress(KeyError, AttributeError):
241237
value = obj.missing_attr
242238
243239
.. note::

docs/parsers/other_parsers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ relationships from multi-voltage-step recordings.
199199
200200
from ionique.parsers import IVCurveParser
201201
202-
parser = IVCurveParser(voltage=voltage_array)
202+
parser = IVCurveParser(voltage_array)
203203
patterns = parser.parse()
204204
# Returns matched voltage patterns for IV analysis
205205

docs/parsers_guide.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ Parsers support JSON serialization for reproducibility:
124124

125125
.. code-block:: python
126126
127-
# Save configuration
128-
json_str = parser.to_json("my_parser.json")
127+
# Save configuration to file
128+
parser.to_json(filename="my_parser.json")
129129
130-
# Reload
131-
from ionique.parsers import Parser
132-
restored = Parser.from_json(json_str)
130+
# Get JSON string without saving to file
131+
json_str = parser.to_json()
132+
133+
.. note::
134+
``from_json`` is defined but not yet fully implemented. Parser
135+
restoration from JSON will be available in a future release.
133136

134137
.. toctree::
135138
:maxdepth: 1

0 commit comments

Comments
 (0)