Skip to content

Commit

Permalink
FUNCZ-352 Translate synapse properties in input to internal naming
Browse files Browse the repository at this point in the history
Otherwise, columns like `gsyn` will be produced again, and be renamed to
`conductance` when writing to disk. If a `conductance` was already
present in the input, this will result in a crash.
  • Loading branch information
matz-e committed Mar 13, 2024
1 parent f597d73 commit 85a8150
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/spykfunc/io/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from spykfunc import schema
from spykfunc.utils import get_logger
from spykfunc.utils.filesystem import adjust_for_spark
from spykfunc.schema import OUTPUT_MAPPING


BASIC_EDGE_SCHEMA = ["source_node_id long", "target_node_id long", "synapse_id long"]
Expand Down Expand Up @@ -541,7 +542,13 @@ def _loader():
edges = parts.repartition(total_parts).mapInPandas(
_create_touch_loader(filename, population), columns
)
return shift_branch_type(edges, -BRANCH_OFFSET).cache()
edges = shift_branch_type(edges, -BRANCH_OFFSET)

for new, (old, _) in OUTPUT_MAPPING.items():
if old in edges.columns:
edges = edges.withColumnRenamed(old, new)

return edges.cache()

return _loader

Expand Down
2 changes: 1 addition & 1 deletion src/spykfunc/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}


# Maps from the internal naming scheme to SONATA one. The third component
# Maps from the internal naming scheme to SONATA one. The second component
# of the tuple specifies the datatype to convert to. If None, no conversion
# is performed.
OUTPUT_MAPPING = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data_input_sonata.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_sonata_properties(tmp_path_factory):
)
fz.process_filters()

assert "delay" in fz.circuit.df.columns
assert "axonal_delay" in fz.circuit.df.columns
assert "gsyn" in fz.circuit.df.columns
assert "u" in fz.circuit.df.columns
assert "d" in fz.circuit.df.columns
Expand Down

0 comments on commit 85a8150

Please sign in to comment.