Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies = [
"numpy>=2.0.2",
"numpy-quaternion>=2023.0.3",
"omegaconf>=2.3.0",
"ompl>=1.7.0",
"opencv-python>=4.11.0.86",
"panel>=1.8.9",
"pillow>=11.3.0",
Expand Down
5 changes: 2 additions & 3 deletions src/ariel/ec/genotypes/nde/nde.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,18 @@ def forward(
self,
genotype: list[npt.NDArray[np.float32]],
) -> list[npt.NDArray[np.float32]]:
"""
Forward pass through the neural developmental encoder.
"""Forward pass through the neural developmental encoder.

Parameters
----------
genotype : list[npt.NDArray[np.float32]]
List of chromosomes (numpy arrays).

Returns
-------
list[npt.NDArray[np.float32]]
List of phenotype outputs (numpy arrays).
"""

outputs: list[npt.NDArray[np.float32]] = []
for idx, chromosome in enumerate(genotype):
with torch.no_grad(): # double safety
Expand Down
37 changes: 34 additions & 3 deletions src/ariel/ec/genotypes/tree/io.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
"""I/O helpers for tree genomes (JSON load/save and networkx conversion).
"""
"""I/O helpers for tree genomes (JSON load/save and networkx conversion)."""
from __future__ import annotations

from typing import Dict, Any
from typing import Any

from .tree_genome import TreeGenome


def load_genome(path: str) -> TreeGenome:
"""Load a TreeGenome from a JSON file.

Parameters
----------
path : str
Path to the JSON file containing the genome.

Returns
-------
TreeGenome
The loaded TreeGenome instance.
"""
return TreeGenome.load_json(path)


def save_genome(genome: TreeGenome, path: str) -> None:
"""Save a TreeGenome to a JSON file.

Parameters
----------
genome : TreeGenome
The TreeGenome instance to save.
genome.save_json(path)
"""


def genome_to_networkx_dict(genome: TreeGenome) -> dict[str, Any]:
"""Convert a TreeGenome to a dictionary format compatible with networkx.

Parameters
----------
genome : TreeGenome
The TreeGenome instance to convert.

Returns
-------
dict[str, Any]
A dictionary representation of the genome suitable for networkx.
"""
return genome.to_dict()
Loading
Loading