Skip to content

Commit

Permalink
Reapply mistakenly removed coordinate callback
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Feb 26, 2024
1 parent e23c15e commit b467bc4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/miv_simulator/simulator/generate_network_architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os.path
import random
import sys
import importlib
from collections import defaultdict

import h5py
Expand Down Expand Up @@ -341,6 +342,26 @@ def generate_network_architecture(
if count <= 0:
continue

if layer.startswith("@"):
# generate via callback
module_path, _, obj_name = layer[1:].rpartition(".")
if module_path == "__main__" or module_path == "":
module = sys.modules["__main__"]
else:
module = importlib.import_module(module_path)
callback = getattr(module, obj_name)

nodes = callback(count, layer_extents[layer])

if not len(nodes) == count:
logger.error(
f"Generator {layer} produced mismatch between actual count {len(nodes)} and configured count {count}"
)

xyz_coords_lst.append(nodes.reshape(-1, 3))

continue

alpha = layer_alpha_shapes[layer]

vert = alpha.points
Expand Down Expand Up @@ -583,6 +604,12 @@ def generate_network_architecture(
for i in range(delta):
for layer, count in pop_layers.items():
if count > 0:
if layer.startswith("@"):
logger.warning(
f"Generator {layer} did not return the specified number of coordinates"
)
continue

min_extent = layer_extents[layer][0]
max_extent = layer_extents[layer][1]
coord_u = np.random.uniform(
Expand Down

0 comments on commit b467bc4

Please sign in to comment.