Skip to content

Commit

Permalink
Merge pull request #1399 from PrincetonUniversity/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
dillontsmith authored Nov 18, 2019
2 parents 0e564cd + 332c260 commit 83772c8
Show file tree
Hide file tree
Showing 82 changed files with 1,482 additions and 1,678 deletions.
10 changes: 4 additions & 6 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branches:
- appveyor
- /devel.*/
- /.*-avy/
- /.*-ci/
- /ci-.*/

environment:
PYTHONWARNINGS: ignore::DeprecationWarning
Expand All @@ -20,10 +20,6 @@ environment:
EXTRA_ARGS: -m llvm
- PYTHON: Python37
EXTRA_ARGS: -m llvm
- PYTHON: Python36
ARCH: -x64
- PYTHON: Python37
ARCH: -x64

install:
- if not exist %GRAPHVIZ_INSTALLER% appveyor-retry curl https://graphviz.gitlab.io/_pages/Download/windows/%GRAPHVIZ_INSTALLER% -o %GRAPHVIZ_INSTALLER%
Expand All @@ -32,7 +28,9 @@ install:
- pip install --user -U pip
- pip --version
# certifi upgrade is needed by pytest-profiling (it does not set the dependencies right)
- pip install --user -U certifi
# Restrict pywin32 to <226 to work around appveyor issue:
# https://help.appveyor.com/discussions/problems/25404-pywin32226-the-specified-module-could-not-be-found
- pip install --user -U certifi "pywin32<226"
- pip install --user git+https://github.com/benureau/leabra.git@master

# pytorch does not distribute windows packages over pypi. Install it directly.
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/pnl-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: PsyNeuLink CI

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 7
matrix:
python-version: [3.6, 3.7, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: windows-latest
python-version: 3.8
- os: macos-latest
python-version: 3.8

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 10
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: MacOS dependencies
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install graphviz
if: matrix.os == 'macos-latest'
- name: Linux dependencies
run: sudo apt-get install -y graphviz
if: matrix.os == 'ubuntu-latest'
- name: Windows dependencies
run: |
choco install --no-progress -y graphviz
python -m pip install --upgrade pip
pip install torch -f https://download.pytorch.org/whl/cpu/torch_stable.html
if: matrix.os == 'windows-latest'
- name: Python3.8 dependencies setup
run: |
sed -i.tmp "/torch/d" requirements.txt
pip install cython llvmlite==0.26
if: matrix.python-version == '3.8'
env:
LLVM_CONFIG: llvm-config-6.0
- name: Shared dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
pip install --user git+https://github.com/benureau/leabra.git@master
- name: Lint with flake8
shell: bash
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: pytest
6 changes: 3 additions & 3 deletions .idea/runConfigurations/Make_HTML.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions .idea/runConfigurations/Scratch_Pad.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ branches:
- devel
- /devel-.*/
- /travis.*/
- /ci-.*/

language: shell

Expand All @@ -13,14 +14,20 @@ os:
dist: bionic

env:
matrix:
jobs:
- PYTHON=3.8.0
- PYTHON=3.7.5
- PYTHON=3.6.8
global:
- PYTHONWARNINGS="ignore::DeprecationWarning"
- PIP_PROGRESS_BAR="off"
- COVERALLS_PARALLEL=true

jobs:
exclude:
- env: PYTHON=3.8.0
os: osx

# Cache downloaded(built) python packages
# and homebrew downloads
cache:
Expand Down Expand Up @@ -59,7 +66,20 @@ before_install:
- |
# Install venv on Linux using Ubuntu distributed python
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-get install -y python${PYTHON%.*}-dev python${PYTHON%.*}-venv
if [ ${PYTHON%.*} == "3.8" ]; then
# There are a lot fewer wheels distributed for python3.8.
# We end up building a lot of them locally. Install the dev packages
EXTRA_PKGS="gfortran llvm-8-dev liblapack-dev python3.8-distutils"
sudo apt-add-repository -y ppa:deadsnakes/ppa
sudo apt-get update
export LLVM_CONFIG=llvm-config-8
export CXXFLAGS=-fPIC
# Drop torch for now
sed -i '/torch/d' requirements.txt
# Cython is needed to build scikit-learn
EXTRA_PIP="cython"
fi
sudo apt-get install -y python${PYTHON%.*}-dev python${PYTHON%.*}-venv $EXTRA_PKGS
python${PYTHON%.*} -m venv $HOME/venv
# Provide fake xdg-open
echo "#!/bin/sh" > $HOME/venv/bin/xdg-open
Expand All @@ -70,6 +90,11 @@ before_install:
- python --version
- pip install -U pip
- pip --version
- |
# Install undeclared dependencies
if [ "x$EXTRA_PIP" != "x" ]; then
pip install $EXTRA_PIP
fi
install:
- pip install coveralls
Expand Down
12 changes: 4 additions & 8 deletions Scripts/Examples/Composition/StabilityFlexibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ def computeAccuracy(variable):
intensity_cost_function=pnl.Linear(slope=0.),
allocation_samples=search_range)





objective_mech = pnl.ObjectiveMechanism(monitor=[inputLayer, stimulusInfo,
(pnl.PROBABILITY_UPPER_THRESHOLD, decisionMaker),
(pnl.PROBABILITY_LOWER_THRESHOLD, decisionMaker)],
Expand All @@ -187,15 +183,15 @@ def computeAccuracy(variable):
control_signals=[signal])

inputs = {inputLayer: INPUT, stimulusInfo: stimulusInput}
stabilityFlexibility.add_model_based_optimizer(meta_controller)
stabilityFlexibility.add_controller(meta_controller)
stabilityFlexibility.enable_model_based_optimizer = True

print("Beginning of Run")

for i in range(1, len(stabilityFlexibility.model_based_optimizer.input_ports)):
stabilityFlexibility.model_based_optimizer.input_ports[i].function.reinitialize()
for i in range(1, len(stabilityFlexibility.controller.input_ports)):
stabilityFlexibility.controller.input_ports[i].function.reinitialize()

stabilityFlexibility.show_graph(show_model_based_optimizer=True)
# stabilityFlexibility.show_graph(show_controller=True)

# stabilityFlexibility.run(inputs)
# print(stabilityFlexibility.results)
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Examples/System/Leabra-Demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# The leabra network and LeabraMechanism experience this bug equally.

# NOTE: The reason TransferMechanisms are used below is because there is currently a bug where LeabraMechanism
# (and other `Mechanism`s with multiple input ports) cannot be used as origin Mechanisms for a System. If you desire
# (and other `Mechanism` with multiple input ports) cannot be used as origin Mechanisms for a System. If you desire
# to use a LeabraMechanism as an origin Mechanism, you can work around this bug by creating two `TransferMechanism`s
# as origin Mechanisms instead, and have these two TransferMechanisms pass their output to the InputPorts of
# the LeabraMechanism.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def objective_function(v):
name='Task Decision',
# function=pnl.NavarroAndFuss,
output_ports=[
pnl.DDM_OUTPUT.PROBABILITY_UPPER_THRESHOLD,
pnl.DDM_OUTPUT.PROBABILITY_LOWER_THRESHOLD
pnl.PROBABILITY_UPPER_THRESHOLD,
pnl.PROBABILITY_LOWER_THRESHOLD
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def adj_cost_fct(v):
t0=.4
),
output_ports=[
pnl.DDM_OUTPUT.PROBABILITY_UPPER_THRESHOLD,
pnl.DDM_OUTPUT.PROBABILITY_LOWER_THRESHOLD,
pnl.DDM_OUTPUT.RESPONSE_TIME
pnl.PROBABILITY_UPPER_THRESHOLD,
pnl.PROBABILITY_LOWER_THRESHOLD,
pnl.RESPONSE_TIME
]
)

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Models (Under Development)/ColorMotionTask_FULL.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def incongruent(colorResponse, motionResponse):
noise=0.5,
t0=0.2,
threshold=0.45),
output_ports=[DDM_OUTPUT.PROBABILITY_UPPER_THRESHOLD, DDM_OUTPUT.RESPONSE_TIME],
output_ports=[PROBABILITY_UPPER_THRESHOLD, RESPONSE_TIME],
)

c = Composition(name='ColorMotion Task')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
noise=0.5,
t0=0.2,
threshold=0.45),
output_ports=[DDM_OUTPUT.PROBABILITY_UPPER_THRESHOLD, DDM_OUTPUT.RESPONSE_TIME],
output_ports=[PROBABILITY_UPPER_THRESHOLD, RESPONSE_TIME],
)

c = Composition(name='ColorMotion Task')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ def objective_function(variable):
agent_comp.enable_controller = True
agent_comp.controller_mode = BEFORE

if SHOW_GRAPH is 'SIMPLE':
if SHOW_GRAPH == 'SIMPLE':
agent_comp.show_graph(show_cim=True)
if SHOW_GRAPH is 'CONTROL':
if SHOW_GRAPH == 'CONTROL':
agent_comp.show_graph(show_model_based_optimizer=True, show_cim=True)
if SHOW_GRAPH is 'NODE STRUCTURE':
if SHOW_GRAPH == 'NODE STRUCTURE':
agent_comp.show_graph(show_model_based_optimizer=True, show_node_structure=True, show_cim=True)
if SHOW_GRAPH is 'FULL':
if SHOW_GRAPH == 'FULL':
agent_comp.show_graph(show_model_based_optimizer=True,
show_cim=True,
show_node_structure=ALL,
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ pytest-helpers-namespace
pytest-xdist
jupyter
sphinx
sphinx_rtd_theme
psyneulink-sphinx-theme
ipykernel
ipython
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
import psyneulink_sphinx_theme
html_theme = "psyneulink_sphinx_theme"
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme_path = [psyneulink_sphinx_theme.get_html_theme_path()]
html_theme_options = {
'navigation_depth': 5
}
Expand Down Expand Up @@ -168,7 +168,7 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = ['css/custom.css']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
Expand Down
4 changes: 2 additions & 2 deletions psyneulink/core/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ def __init__(self,
self.componentName = self.componentType

# ENFORCE REGISRY
if self.__class__.__bases__[0].__bases__[0].__bases__[0].__name__ is 'ShellClass':
if self.__class__.__bases__[0].__bases__[0].__bases__[0].__name__ == 'ShellClass':
try:
self.__class__.__bases__[0].registry
except AttributeError:
Expand Down Expand Up @@ -2846,7 +2846,7 @@ def _get_param_value_from_tuple(self, param_spec):
ALLOWABLE_TUPLE_SPEC_CLASSES = (ModulatoryProjection_Base, ModulatorySignal, ModulatoryMechanism_Base)

# If the 2nd item is a CONTROL or LEARNING SPEC, return the first item as the value
if (isinstance(param_spec, tuple) and len(param_spec) is 2 and
if (isinstance(param_spec, tuple) and len(param_spec) == 2 and
not isinstance(param_spec[1], (dict, list, np.ndarray)) and
(param_spec[1] in ALLOWABLE_TUPLE_SPEC_KEYWORDS or
isinstance(param_spec[1], ALLOWABLE_TUPLE_SPEC_CLASSES) or
Expand Down
7 changes: 6 additions & 1 deletion psyneulink/core/components/functions/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
from psyneulink.core.globals.preferences.basepreferenceset import is_pref_set, REPORT_OUTPUT_PREF
from psyneulink.core.globals.preferences.preferenceset import PreferenceEntry, PreferenceLevel
from psyneulink.core.globals.registry import register_category
from psyneulink.core.globals.utilities import object_has_single_value, parameter_spec, safe_len
from psyneulink.core.globals.utilities import object_has_single_value, parameter_spec, safe_len, get_global_seed

__all__ = [
'ArgumentTherapy', 'EPSILON', 'Function_Base', 'function_keywords', 'FunctionError', 'FunctionOutputType',
Expand Down Expand Up @@ -521,6 +521,11 @@ def __deepcopy__(self, memo):
new = super().__deepcopy__(memo)
# ensure copy does not have identical name
register_category(new, Function_Base, new.name, FunctionRegistry)
try:
# HACK: Make sure any copies are re-seeded to avoid dependent RNG.
new.random_state.seed([get_global_seed()])
except:
pass
return new

@handle_external_context()
Expand Down
Loading

0 comments on commit 83772c8

Please sign in to comment.