Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcpni committed Dec 19, 2024
1 parent 7b4222b commit f1e64b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
21 changes: 11 additions & 10 deletions psyneulink/core/components/functions/nonstateful/timerfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* **AcceleratingTimer** - advances from initial <TimerFunction.initial>` to `final <TimerFunction.final>` value
by progressively larger amounts at an adjustable exponential `rate <AcceleratingTimerRise.rate>`
(see `interactive graph <https://www.desmos.com/calculator/rms6z2ji8g>`_).
* **DeceleratingTimer** - advances from initial <TimerFunction.initial>` to `final <TimerFunction.final>` value
by progressively smaller amounts at an adjustable exponential `rate <DeceleratingTimer.rate>`
(see `interactive graph <https://www.desmos.com/calculator/cshkzip0ai>`_).
Expand Down Expand Up @@ -606,12 +606,12 @@ def derivative(self, input, output=None, context=None):
duration = self._get_current_parameter_value(DURATION, context)
rate = self._get_current_parameter_value(RATE, context)

return ((final - initial) *
(rate * (input / duration)^(rate - 1)
* ((1 / duration)
* (np.exp(np.power((input / duration),rate) - 1)
+ (np.power((input / duration),rate))
* np.exp(np.power((input / duration),rate) - 1) * rate * 1 / duration))))
return ((final - initial) *
(rate * np.power((input / duration), (rate - 1))
* ((1 / duration)
* (np.exp(np.power((input / duration), rate) - 1)
+ (np.power((input / duration), rate))
* np.exp(np.power((input / duration), rate) - 1) * rate * 1 / duration))))

# FIX:
def _gen_llvm_transfer(self, builder, index, ctx, vi, vo, params, state, *, tags:frozenset):
Expand Down Expand Up @@ -887,9 +887,10 @@ def derivative(self, input, output=None, context=None):
rate = self._get_current_parameter_value(RATE, context)
direction = 1 if final > initial else -1

return direction * rate * (initial - final - direction) * np.log(direction * (final - initial + direction)) * \
(input / duration)^(rate - 1) / (duration * np.exp(np.log(direction * (final - initial + direction)) *
np.power((input / duration),rate)))
return (direction * rate * (initial - final - direction) * np.log(direction * (final - initial + direction)) * \
np.power((input / duration), (rate - 1))
/ (duration * np.exp(np.log(direction * (final - initial + direction)) *
np.power((input / duration), rate))))

# FIX:
def _gen_llvm_transfer(self, builder, index, ctx, vi, vo, params, state, *, tags:frozenset):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
from psyneulink.core.components.functions.stateful.statefulfunction import StatefulFunction
from psyneulink.core.globals.context import ContextFlags, handle_external_context
from psyneulink.core.globals.keywords import \
(ACCUMULATOR_INTEGRATOR_FUNCTION, ADAPTIVE_INTEGRATOR_FUNCTION, ADDITIVE_PARAM, \
DECAY, DEFAULT_VARIABLE, DRIFT_DIFFUSION_INTEGRATOR_FUNCTION, DRIFT_ON_A_SPHERE_INTEGRATOR_FUNCTION, \
DUAL_ADAPTIVE_INTEGRATOR_FUNCTION, FITZHUGHNAGUMO_INTEGRATOR_FUNCTION, FUNCTION, \
(ACCUMULATOR_INTEGRATOR_FUNCTION, ADAPTIVE_INTEGRATOR_FUNCTION, ADDITIVE_PARAM,
DECAY, DEFAULT_VARIABLE, DRIFT_DIFFUSION_INTEGRATOR_FUNCTION, DRIFT_ON_A_SPHERE_INTEGRATOR_FUNCTION,
DUAL_ADAPTIVE_INTEGRATOR_FUNCTION, FITZHUGHNAGUMO_INTEGRATOR_FUNCTION, FUNCTION,
INCREMENT, INITIALIZER, INPUT_PORTS, INTEGRATOR_FUNCTION, INTEGRATOR_FUNCTION_TYPE,
INTERACTIVE_ACTIVATION_INTEGRATOR_FUNCTION, LEAKY_COMPETING_INTEGRATOR_FUNCTION, \
INTERACTIVE_ACTIVATION_INTEGRATOR_FUNCTION, LEAKY_COMPETING_INTEGRATOR_FUNCTION,
MODEL_SPEC_ID_MDF_VARIABLE, MULTIPLICATIVE_PARAM, NOISE, OFFSET, OPERATION, ORNSTEIN_UHLENBECK_INTEGRATOR_FUNCTION,
OUTPUT_PORTS, PREVIOUS_VALUE, PRODUCT, RATE, REST, SCALE, SIMPLE_INTEGRATOR_FUNCTION, SUM, TIME_STEP_SIZE,
THRESHOLD, VARIABLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*TIMER_MECHANISM* as its **mech_spec** argument. It can be created with or without a source of input. By default, a
TimerMechanisms increments linearly, starting at 0, incrementing by 0.01 each time it is executed, and stopping when it
reaches 1. However, the shape, starting, ending and rate of increment can all be configured. The shape of the timer's
progression is specified by it **trajectory** argument, which must be a `TimerFunction` or an appropriately configured
progression is specified by it **trajectory** argument, which must be a `TimerFunction` or an appropriately configured
`UserDefinedFunction` (see `below <TimerMechanism_Trajectory_Function>` for details); the starting and ending `values
<Mechanism_Base.value>` of the timer are specified by its **start** and **end** arguments, respectively, and the ammount
it progresses each time the Mechanimsm is executed (in the absence of input) is specified by its **increment** argument.
Expand Down Expand Up @@ -196,7 +196,7 @@ class TimerMechanism(IntegratorMechanism):
start : scalar, list or array : default 0
specifies the starting `value <Mechanism_Base.value>` of the timer; if a list or array, the length must be
the same as specified for **default_variable** or **input_shapes** (see `TimerMechanism_Execution` for
the same as specified for **default_variable** or **input_shapes** (see `TimerMechanism_Execution` for
additional details).
increment : scalar, list or array : default 1
Expand Down Expand Up @@ -410,4 +410,3 @@ def _execute(self, variable=None, context=None, runtime_params=None, **kwargs):
def reset(self, *args, force=False, context=None, **kwargs):
super().reset(*args, force=force, context=context, **kwargs)
self.finished = False

0 comments on commit f1e64b1

Please sign in to comment.