From f5ffc56f69471a0ef81e246238590aacfbed1526 Mon Sep 17 00:00:00 2001 From: Trevor Bekolay Date: Thu, 18 Oct 2018 19:19:47 -0400 Subject: [PATCH] Use Python 3 only We were using some compatibility functions in nengo.utils.compat out of habit, but since we are only supporting Python 3 they were unnecessary. --- nengo_loihi/builder.py | 3 +-- nengo_loihi/loihi_cx.py | 2 +- nengo_loihi/simulator.py | 1 - nengo_loihi/splitter.py | 5 ++--- nengo_loihi/tests/test_splitter.py | 7 +++---- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/nengo_loihi/builder.py b/nengo_loihi/builder.py index a2da0dece..504c88d27 100644 --- a/nengo_loihi/builder.py +++ b/nengo_loihi/builder.py @@ -12,7 +12,6 @@ from nengo.exceptions import BuildError from nengo.solvers import NoSolver, Solver from nengo.utils.builder import default_n_eval_points -from nengo.utils.compat import iteritems import nengo.utils.numpy as npext from nengo_loihi.loihi_cx import ( @@ -841,7 +840,7 @@ def signal_probe(model, key, probe): @Builder.register(Probe) def build_probe(model, probe): # find the right parent class in `objtypes`, using `isinstance` - for nengotype, probeables in iteritems(probemap): + for nengotype, probeables in probemap.items(): if isinstance(probe.obj, nengotype): break else: diff --git a/nengo_loihi/loihi_cx.py b/nengo_loihi/loihi_cx.py index 49b6be509..0f4dc0078 100644 --- a/nengo_loihi/loihi_cx.py +++ b/nengo_loihi/loihi_cx.py @@ -6,7 +6,7 @@ import numpy as np from nengo.exceptions import BuildError, SimulationError -from nengo.utils.compat import is_iterable, range +from nengo.utils.compat import is_iterable from nengo_loihi.loihi_api import ( BIAS_MAX, diff --git a/nengo_loihi/simulator.py b/nengo_loihi/simulator.py index 93d92982e..89098d2c3 100644 --- a/nengo_loihi/simulator.py +++ b/nengo_loihi/simulator.py @@ -8,7 +8,6 @@ from nengo.exceptions import ( BuildError, ReadonlyError, SimulatorClosed, ValidationError) from nengo.simulator import ProbeDict as NengoProbeDict -from nengo.utils.compat import ResourceWarning from nengo_loihi.builder import Model from nengo_loihi.loihi_cx import CxGroup diff --git a/nengo_loihi/splitter.py b/nengo_loihi/splitter.py index 3373aa7e9..c7335f407 100644 --- a/nengo_loihi/splitter.py +++ b/nengo_loihi/splitter.py @@ -3,7 +3,6 @@ import nengo from nengo.exceptions import BuildError, SimulationError -from nengo.utils.compat import iteritems import numpy as np from nengo_loihi import loihi_cx @@ -74,9 +73,9 @@ def _add(obj, net): "%s not moved or explicitly removed" % (obj,)) # Process moves and adds - for obj, target in iteritems(self.moves): + for obj, target in self.moves.items(): _add(obj, getattr(self, target)) - for obj, target in iteritems(self.adds): + for obj, target in self.adds.items(): _add(obj, getattr(self, target)) def location(self, obj, default=None): diff --git a/nengo_loihi/tests/test_splitter.py b/nengo_loihi/tests/test_splitter.py index b5dafa92a..881745adf 100644 --- a/nengo_loihi/tests/test_splitter.py +++ b/nengo_loihi/tests/test_splitter.py @@ -1,6 +1,5 @@ import pytest import nengo -from nengo.utils.compat import iteritems, itervalues import numpy as np from nengo_loihi.config import add_params @@ -147,7 +146,7 @@ def test_split_host_neurons_to_chip(): def assert_split_correctly(split_conn): assert len(networks.adds) == 4 added_types = sorted([(type(obj).__name__, location) - for obj, location in iteritems(networks.adds)]) + for obj, location in networks.adds.items()]) assert added_types == [ ("ChipReceiveNeurons", "chip"), ("Connection", "chip"), @@ -309,9 +308,9 @@ def test_split_host_to_learning_rule(): "Connection", "Connection", "HostSendNode", "HostSendNode", ] assert off2on_ens in networks.removes - assert "ens_pes_target" in list(itervalues(networks.host2chip_senders)) + assert "ens_pes_target" in list(networks.host2chip_senders.values()) assert off2on_neurons in networks.removes - assert "neurons_pes_target" in list(itervalues(networks.host2chip_senders)) + assert "neurons_pes_target" in list(networks.host2chip_senders.values()) def test_place_probes():