nebius/SWE-bench-extra huggingface dataset:
Repository: chriskuehl/rustenv

Issue:
`deactivate_rustenv` doesn't remove `deactivate_rustenv`
```console
(renv) asottile@babibox:/tmp
$ deactivate_rustenv 
asottile@babibox:/tmp
$ which cargo
asottile@babibox:/tmp
$ deactivate_rustenv 
ehco hi
bash: ehco: No such file or directory
echo hi
hi
```

Comments:

Patch:
diff --git a/rustenv.py b/rustenv.py
index ac82bb7..4cdbbc2 100644
--- a/rustenv.py
+++ b/rustenv.py
@@ -47,6 +47,7 @@ deactivate_rustenv() {{
     unset _RUSTENV_BIN_PATH
     unset _RUSTENV_OLD_PS1
     unset _RUSTENV_OLD_PATH
+    unset -f deactivate_rustenv
 }}
 '''
 


Test patch:
diff --git a/tests/integration_test.py b/tests/integration_test.py
index 72088d5..e1b3e5c 100644
--- a/tests/integration_test.py
+++ b/tests/integration_test.py
@@ -22,6 +22,7 @@ report() {{
     echo "[[$1-rustc:$(rustc --version 2>&1)]]"
     echo "[[$1-cargo:$(cargo --version 2>&1)]]"
     echo "[[$1-hello:$(hello 2>&1)]]"
+    echo "[[$1-deactivate_rustenv:$(type deactivate_rustenv | head -1)]]"
 }}
 
 report start
Repository: chriskuehl/rustenv

Issue:
activate script doesn't work if there's no PS1 and the shell is `set -e`
This happens e.g. in bash scripts (as opposed to logged-in sessions).

```
$ cat test.sh
#!/bin/bash
set -euo pipefail
. renv/bin/activate

$ ./test.sh  
renv/bin/activate: line 6: PS1: unbound variable
```

It should probably skip setting the PS1 in this case entirely?

Comments:

Patch:
diff --git a/rustenv.py b/rustenv.py
index 4cdbbc2..f2b8aff 100644
--- a/rustenv.py
+++ b/rustenv.py
@@ -31,15 +31,17 @@ _RUSTENV_NAME='{RUSTENV_NAME}'
 
 # TODO: it might be nice to intelligently add/remove from PATH/PS1 instead of
 # just restoring the old one
-_RUSTENV_OLD_PS1="$PS1"
+_RUSTENV_OLD_PS1="${{PS1-}}"
 _RUSTENV_OLD_PATH="$PATH"
 
 export PATH="$_RUSTENV_BIN_PATH:$PATH"
-export PS1="($_RUSTENV_NAME) $PS1"
+export PS1="($_RUSTENV_NAME) ${{PS1-}}"
 hash -r 2>/dev/null
 
 deactivate_rustenv() {{
-    export PS1="$_RUSTENV_OLD_PS1"
+    if ! [ -z "${{_RUSTENV_OLD_PS1+_}}" ] ; then
+        export PS1="$_RUSTENV_OLD_PS1"
+    fi
     export PATH="$_RUSTENV_OLD_PATH"
     hash -r 2>/dev/null
 


Test patch:
diff --git a/tests/integration_test.py b/tests/integration_test.py
index e1b3e5c..073695d 100644
--- a/tests/integration_test.py
+++ b/tests/integration_test.py
@@ -102,3 +102,16 @@ def test_runenv_shell(shell, not_found_message, built_rustenv, tmpdir):
 
     assert stages['installed']['hello'] == 'Hello World!'
     assert stages['uninstalled'] == stages['activated']
+
+
+@pytest.mark.parametrize('shell', ('bash', 'zsh'))
+def test_works_without_ps1(shell, built_rustenv, tmpdir):
+    test_script = tmpdir.join('test.sh')
+    test_script.write(
+        """
+        unset PS1
+        set -euo pipefail
+        . {}/bin/activate
+        """.format(built_rustenv.strpath),
+    )
+    subprocess.check_output((shell, test_script.strpath))
Repository: circus-tent/circus

Issue:
mem_info not reliable
The human friendly representation gives integer representation instead of float which gives unreliable stats.
```
>>> from circus.util import bytes2human
>>> bytes2human(1024 * 1024 * 2047)
'1G'
>>> bytes2human(1024 * 1024 * 2048)
'2G'
```

The first example should return `1.99G` ideally. This is not critical when talking about megas but when we start talking about gigas or more it gets problematic.

Also why not always give a MiB representation in float (not string) ?


Comments:

Patch:
diff --git a/circus/util.py b/circus/util.py
index 76bf43a7..e7324ce4 100644
--- a/circus/util.py
+++ b/circus/util.py
@@ -144,8 +144,8 @@ def bytes2human(n):
 
     for s in reversed(_SYMBOLS):
         if n >= prefix[s]:
-            value = int(float(n) / prefix[s])
-            return '%s%s' % (value, s)
+            value = round(float(n) / prefix[s], 2)
+            return '{:.2f}{}'.format(value, s)
     return "%sB" % n
 
 


Test patch:
diff --git a/circus/tests/test_util.py b/circus/tests/test_util.py
index 1b4256d0..e74f48e1 100644
--- a/circus/tests/test_util.py
+++ b/circus/tests/test_util.py
@@ -92,8 +92,10 @@ class TestUtil(TestCase):
         self.assertEqual(util.convert_opt('test', 1), '1')
 
     def test_bytes2human(self):
-        self.assertEqual(bytes2human(10000), '9K')
-        self.assertEqual(bytes2human(100001221), '95M')
+        self.assertEqual(bytes2human(100), '100B')
+        self.assertEqual(bytes2human(10000), '9.77K')
+        self.assertEqual(bytes2human(100001221), '95.37M')
+        self.assertEqual(bytes2human(1024 * 1024 * 2047), '2.00G')
         self.assertRaises(TypeError, bytes2human, '1')
 
     def test_human2bytes(self):
@@ -102,6 +104,8 @@ class TestUtil(TestCase):
         self.assertEqual(human2bytes('1129M'), 1183842304)
         self.assertEqual(human2bytes('67T'), 73667279060992)
         self.assertEqual(human2bytes('13P'), 14636698788954112)
+        self.assertEqual(human2bytes('1.99G'), 2136746229)
+        self.assertEqual(human2bytes('2.00G'), 2147483648)
         self.assertRaises(ValueError, human2bytes, '')
         self.assertRaises(ValueError, human2bytes, 'faoej')
         self.assertRaises(ValueError, human2bytes, '123KB')