Clean up syntax for supported Python versions. (#1963)

* Use set/dict literal syntax

Ran code through [pyupgrade](https://github.com/asottile/pyupgrade). This is
supported in every Python version 2.7+.

* Drop unnecessary string format specification

No need to specify 0,1.. if paramters are passed in order.

* Revert "Drop unnecessary string format specification"

This reverts commit efa5ec85d30ff69f34e5ed93e31343fea7647bcb.

* Undo changes to cloudpickle

Drop use of set literal until cloudpickle uses it.

* Reformat code with YAPF

We need to set up a git pre-push hook to automatically run this stuff.
This commit is contained in:
Alok Singh
2018-05-03 07:45:11 -07:00
committed by Philipp Moritz
parent d85ee0bc04
commit cdf94c18a4
11 changed files with 41 additions and 37 deletions
+8 -8
View File
@@ -688,36 +688,36 @@ class PopulationBasedTestingSuite(unittest.TestCase):
# Categorical case
assertProduces(
lambda: explore({"v": 4}, {"v": [3, 4, 8, 10]}, 0.0, lambda x: x),
set([3, 8]))
{3, 8})
assertProduces(
lambda: explore({"v": 3}, {"v": [3, 4, 8, 10]}, 0.0, lambda x: x),
set([3, 4]))
{3, 4})
assertProduces(
lambda: explore({"v": 10}, {"v": [3, 4, 8, 10]}, 0.0, lambda x: x),
set([8, 10]))
{8, 10})
assertProduces(
lambda: explore({"v": 7}, {"v": [3, 4, 8, 10]}, 0.0, lambda x: x),
set([3, 4, 8, 10]))
{3, 4, 8, 10})
assertProduces(
lambda: explore({"v": 4}, {"v": [3, 4, 8, 10]}, 1.0, lambda x: x),
set([3, 4, 8, 10]))
{3, 4, 8, 10})
# Continuous case
assertProduces(
lambda: explore(
{"v": 100}, {"v": lambda: random.choice([10, 100])}, 0.0,
lambda x: x),
set([80, 120]))
{80, 120})
assertProduces(
lambda: explore(
{"v": 100.0}, {"v": lambda: random.choice([10, 100])}, 0.0,
lambda x: x),
set([80.0, 120.0]))
{80.0, 120.0})
assertProduces(
lambda: explore(
{"v": 100.0}, {"v": lambda: random.choice([10, 100])}, 1.0,
lambda x: x),
set([10.0, 100.0]))
{10.0, 100.0})
def testYieldsTimeToOtherTrials(self):
pbt, runner = self.basicSetup()
+1 -1
View File
@@ -172,7 +172,7 @@ class TrialRunner(object):
if max_debug == start_num:
break
for local_dir in sorted(set([t.local_dir for t in self._trials])):
for local_dir in sorted({t.local_dir for t in self._trials}):
messages.append("Result logdir: {}".format(local_dir))
for state, trials in sorted(states.items()):
limit = limit_per_state[state]