Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Oct 4, 2024
1 parent 6afc917 commit 83b9368
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions neurots/generate/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

from collections import deque

from functools import partial
import numpy as np
from numpy.linalg import norm as vectorial_norm # vectorial_norm used for array of vectors

Expand Down Expand Up @@ -85,7 +85,7 @@ def update_pathlength(self, length):
"""Increases the path distance."""
self.pathlength += length

def _propose(self, extra_randomness=None, add_random_component=True):
def _propose(self, extra_randomness=0, add_random_component=True):
"""Propose the direction for a next section point.
Args:
Expand All @@ -96,13 +96,13 @@ def _propose(self, extra_randomness=None, add_random_component=True):

if add_random_component:
random_component = self.params.randomness * get_random_point(random_generator=self._rng)
if extra_randomness is not None:
if extra_randomness > 0:
random_component *= extra_randomness

Check warning on line 100 in neurots/generate/section.py

View check run for this annotation

Codecov / codecov/patch

neurots/generate/section.py#L100

Added line #L100 was not covered by tests
direction += random_component

return direction / vectorial_norm(direction)

def next_point(self, add_random_component=True, extra_randomness=None):
def next_point(self, add_random_component=True, extra_randomness=0):
"""Returns the next point depending on the growth method and the previous point.
If a context is present, an accept-reject mechanism will be used to alter the next point.
Expand Down Expand Up @@ -138,7 +138,10 @@ def prob(*args, **kwargs):
randomness_increase = DEFAULT_RANDOMNESS_INCREASE

direction = accept_reject(
self._propose,
partial(
self._propose,
add_random_component=add_random_component,
),
prob,
self._rng,
max_tries=max_tries,
Expand Down

0 comments on commit 83b9368

Please sign in to comment.