Skip to content

Commit

Permalink
Merge pull request #2886 from jvesely/devel
Browse files Browse the repository at this point in the history
requirements: Add scipy to requirements file
  • Loading branch information
davidt0x authored Jan 23, 2024
2 parents d40210b + 8ce059a commit 3380105
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import numpy as np
from beartype import beartype
from scipy.special import erfinv

from psyneulink._typing import Optional

Expand Down Expand Up @@ -371,11 +372,6 @@ def _function(self,
params=None,
):

try:
from scipy.special import erfinv
except:
raise FunctionError("The UniformToNormalDist function requires the SciPy package.")

mean = self._get_current_parameter_value(DIST_MEAN, context)
standard_deviation = self._get_current_parameter_value(STANDARD_DEVIATION, context)
random_state = self.parameters.random_state._get(context)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ pillow<10.3.0
pint<0.22.0
protobuf<3.20.4
rich>=10.1, <10.13
scipy<1.12
toposort<1.11
torch>=1.10.0, <2.2.0; (platform_machine == 'AMD64' or platform_machine == 'x86_64' or platform_machine == 'arm64' or platform_machine == 'aarch64') and platform_python_implementation == 'CPython' and implementation_name == 'cpython'
38 changes: 12 additions & 26 deletions tests/mechanisms/test_transfer_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,33 +299,19 @@ def test_transfer_mech_exponential_noise(self):
@pytest.mark.mechanism
@pytest.mark.transfer_mechanism
def test_transfer_mech_uniform_to_normal_noise(self):
try:
import scipy
except ModuleNotFoundError:
with pytest.raises(FunctionError) as error_text:
T = TransferMechanism(
name='T',
default_variable=[0, 0, 0, 0],
function=Linear(),
noise=UniformToNormalDist(),
integration_rate=1.0
)
assert "The UniformToNormalDist function requires the SciPy package." in str(error_text.value)
else:
T = TransferMechanism(
name='T',
default_variable=[0, 0, 0, 0],
function=Linear(),
noise=UniformToNormalDist(),
integration_rate=1.0
)
# This is equivalent to
# T.noise.base.parameters.random_state.get(None).seed([22])
T.noise.parameters.seed.set(22, None)
val = T.execute([0, 0, 0, 0])
np.testing.assert_allclose(val, [[1.73027452, -1.07866481, -1.98421126, 2.99564032]])


T = TransferMechanism(
name='T',
default_variable=[0, 0, 0, 0],
function=Linear(),
noise=UniformToNormalDist(),
integration_rate=1.0
)
# This is equivalent to
# T.noise.base.parameters.random_state.get(None).seed([22])
T.noise.parameters.seed.set(22, None)
val = T.execute([0, 0, 0, 0])
np.testing.assert_allclose(val, [[1.73027452, -1.07866481, -1.98421126, 2.99564032]])

@pytest.mark.mechanism
@pytest.mark.transfer_mechanism
Expand Down

0 comments on commit 3380105

Please sign in to comment.