anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: weasyl/weasyl
Issue: Hidden journals not accessible using moderation tools

Hidden submissions can be accessed using the moderation tools (by way of ?anyway=true links), however this functionality is not working for journals.


Changed files:
weasyl/journal.py, weasyl/character.py

diff --git a/weasyl/character.py b/weasyl/character.py
index 85c1a47..ba6931e 100644
--- a/weasyl/character.py
+++ b/weasyl/character.py
@@ -232,7 +232,7 @@ def _select_character_and_check(userid, charid, rating=None, ignore=True, anyway
 
 def select_view(userid, charid, rating, ignore=True, anyway=None):
     query = _select_character_and_check(
-        userid, charid, rating=rating, ignore=ignore, anyway=anyway == 'anyway')
+        userid, charid, rating=rating, ignore=ignore, anyway=anyway == "true")
 
     login = define.get_sysname(query['username'])
 
diff --git a/weasyl/journal.py b/weasyl/journal.py
index 0107b7e..496189c 100644
--- a/weasyl/journal.py
+++ b/weasyl/journal.py
@@ -109,7 +109,7 @@ def _select_journal_and_check(userid, journalid, rating=None, ignore=True, anywa
 
 def select_view(userid, rating, journalid, ignore=True, anyway=None):
     journal = _select_journal_and_check(
-        userid, journalid, rating=rating, ignore=ignore, anyway=anyway == 'anyway')
+        userid, journalid, rating=rating, ignore=ignore, anyway=anyway == "true")
 
     return {
         'journalid': journalid,
Repository: weasyl/weasyl
Issue: Updating streaming settings of another user returns you to your own settings page

(Previously GitLab issue 32, Redmine issue 429)

Using the moderator tools to update the streaming settings of another user "returns" you to your own settings page. This should return you to the previously used page (User Management).


Changed files:
weasyl/controllers/settings.py

diff --git a/weasyl/controllers/settings.py b/weasyl/controllers/settings.py
index e658e57..23b6508 100644
--- a/weasyl/controllers/settings.py
+++ b/weasyl/controllers/settings.py
@@ -376,7 +376,11 @@ def control_streaming_post_(request):
                                     set_stream=set_stream,
                                     stream_length=stream_length)
 
-    raise HTTPSeeOther(location="/control")
+    if form.target:
+        target_username = define.get_sysname(define.get_display_name(target))
+        raise HTTPSeeOther(location="/modcontrol/manageuser?name=" + target_username)
+    else:
+        raise HTTPSeeOther(location="/control")
 
 
 @login_required
Repository: dwavesystems/dimod
Issue: Response futures appear to be strings?

```
from dwave.system.samplers import DWaveSampler

sampler = DWaveSampler(profile='BAY4')

h = {}
J = {(0, 4): -1}

response = sampler.sample_ising(h, J, num_reads=10)
print response.done()
```
yields
```
AttributeError: 'str' object has no attribute 'done'
```
If I print `response._futures` right after creating the response, I get 
```
{'ignore_extra_keys': True, 'samples_key': 'samples', 'futures': (<dwave.cloud.computation.Future object at 0x7f31793d8110>,), 'data_vector_keys': {'energies': 'energy', 'num_occurrences': 'num_occurrences'}, 'active_variables': [0, 4], 'variable_labels': [0, 4], 'info_keys': {'timing': 'timing'}}
```
Is it possible `response._futures` is temporarily overwritten somewhere? Apparently yes, `response._futures` can hold something else than futures: at https://github.com/dwavesystems/dimod/blob/master/dimod/response.py#L561, it gets populated with a bunch of stuff, including non-futures.

So `response._futures` can be different things at different stages of the response ... :-1: 

Changed files:
dimod/response.py, tests/test_response.py

diff --git a/dimod/response.py b/dimod/response.py
index 1378ed70..e2b30309 100644
--- a/dimod/response.py
+++ b/dimod/response.py
@@ -230,7 +230,7 @@ class Response(Iterable, Sized):
             True
 
         """
-        return all(future.done() for future in self._futures)
+        return all(future.done() for future in self._futures.get('futures', tuple()))
 
     ##############################################################################################
     # Construction and updates
@@ -559,7 +559,7 @@ class Response(Iterable, Sized):
         response = cls.empty(vartype)
 
         # now dump all of the remaining information into the _futures
-        response._futures = {'futures': futures,
+        response._futures = {'futures': list(futures),
                              'samples_key': samples_key,
                              'data_vector_keys': data_vector_keys,
                              'info_keys': info_keys,
diff --git a/tests/test_response.py b/tests/test_response.py
index bd18948e..c3c0ddf3 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -301,6 +301,8 @@ class TestResponse(unittest.TestCase):
 
         response = dimod.Response.from_futures(_futures(), vartype=dimod.SPIN, num_variables=3)
 
+        self.assertTrue(response.done())
+
         matrix = response.samples_matrix
 
         npt.assert_equal(matrix, np.matrix([[-1, -1, 1], [-1, -1, 1]]))
Repository: dwavesystems/dimod
Issue: Embedding/weight_random failing: NameError: global name 'random' is not defined

It works only if I change line 160 in chain_breaks.py from "unembedded[v] = random.choice(vals)" to "unembedded[v] = np.random.choice(vals)"

In [284]: next(dimod.embedding.weighted_random(sample, embedding))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-284-c5974cb75d13> in <module>()
----> 1 next(dimod.embedding.weighted_random(sample, embedding))

C:\\Users\\jpasvolsky\\!git_DocsOS\\env\\ADTT\\dimod\\dimod\\embedding\\chain_breaks.pyc in weighted_random(sample, embedding)
    124     for v, chain in iteritems(embedding):
    125         vals = [sample[u] for u in chain]
--> 126
    127         if _all_equal(vals):
    128             unembedded[v] = vals.pop()

NameError: global name 'random' is not defined

Changed files:
dimod/embedding/chain_breaks.py

diff --git a/dimod/embedding/chain_breaks.py b/dimod/embedding/chain_breaks.py
index 34fca00a..fd7621ef 100644
--- a/dimod/embedding/chain_breaks.py
+++ b/dimod/embedding/chain_breaks.py
@@ -123,7 +123,7 @@ def weighted_random(sample, embedding):
 
         # pick a random element uniformly from all vals, this weights them by
         # the proportion of each
-        unembedded[v] = random.choice(vals)
+        unembedded[v] = np.random.choice(vals)
 
     yield unembedded
Repository: dwavesystems/dimod
Issue: Missing itertools import

**Description**

Missing itertools import in `sampleset.py`

https://github.com/dwavesystems/dimod/blob/30c9b5a8bc289aee9b276a4ebc2ce27e8413e2f9/dimod/sampleset.py#L517

**Steps To Reproduce**
```
resp.samples(n=1)
```



Changed files:
dimod/sampleset.py, tests/test_sampleset.py

diff --git a/dimod/sampleset.py b/dimod/sampleset.py
index 682aac68..70e3795f 100644
--- a/dimod/sampleset.py
+++ b/dimod/sampleset.py
@@ -21,6 +21,8 @@ of NumPy's array_like_ to allow for arbitrary variable labels.
     like-objects-to-numpy-arrays
 
 """
+import itertools
+
 from collections import Iterable, Sized, Mapping, Iterator
 from collections import namedtuple
 
diff --git a/tests/test_sampleset.py b/tests/test_sampleset.py
index 0e952b2e..2c2b8be4 100644
--- a/tests/test_sampleset.py
+++ b/tests/test_sampleset.py
@@ -83,6 +83,11 @@ class TestSampleSet(unittest.TestCase):
         self.assertNotEqual(ss0, ss2)
         self.assertNotEqual(ss1, ss3)
 
+    def test_shorter_samples(self):
+        ss = dimod.SampleSet.from_samples(np.ones((100, 5), dtype='int8'), dimod.BINARY, energy=np.ones(100))
+
+        self.assertEqual(len(list(ss.samples(n=1))), 1)
+
 
 class TestSampleSetSerialization(unittest.TestCase):