Skip to content

Commit

Permalink
bug fix, type/io_class_name may be None
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Aug 25, 2023
1 parent cc93cbc commit ec54f28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def load_block(url, io_class_name=None):
# todo: handle formats with multiple files, or with a directory
if io_class_name:
# todo: handle an invalid class name
io_cls = getattr(neo.io, io_class_name)
io_cls = getattr(neo.io, io_class_name.value)
try:
io = io_cls(filename=file_path)
except ImportError:
Expand Down
8 changes: 4 additions & 4 deletions api/resources/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def get_block_data(
but without any information about the data contained within each segment.
"""
# here `url` is a Pydantic object, which we convert to a string
block = load_block(str(url), type.value)
block = load_block(str(url), type)
return BlockContainer.from_neo(block, url)


Expand Down Expand Up @@ -86,7 +86,7 @@ async def get_segment_data(
including metadata about the signals contained in the segment,
but not the signal data themselves.
"""
block = load_block(str(url), type.value)
block = load_block(str(url), type)
try:
segment = block.segments[segment_id]
except IndexError:
Expand Down Expand Up @@ -129,7 +129,7 @@ async def get_analogsignal_data(
] = 1,
) -> AnalogSignal:
"""Get an analog signal from a given segment, including both data and metadata."""
block = load_block(str(url), type.value)
block = load_block(str(url), type)
try:
segment = block.segments[segment_id]
except IndexError:
Expand Down Expand Up @@ -173,7 +173,7 @@ async def get_spiketrain_data(
] = None,
) -> dict[str, SpikeTrain]:
"""Get the spike trains from a given segment, including both data and metadata."""
block = load_block(str(url), type.value)
block = load_block(str(url), type)
try:
segment = block.segments[segment_id]
except IndexError:
Expand Down

0 comments on commit ec54f28

Please sign in to comment.