nebius/SWE-bench-extra huggingface dataset:
Repository: PEtab-dev/libpetab-python

Issue:
Reduce tests to min+max python?
takes quite some time to start+run all ...

Comments:

Patch:
diff --git a/petab/lint.py b/petab/lint.py
index ba9ad8f..e13f540 100644
--- a/petab/lint.py
+++ b/petab/lint.py
@@ -292,7 +292,12 @@ def check_observable_df(observable_df: pd.DataFrame) -> None:
 
         noise = getattr(row, NOISE_FORMULA)
         try:
-            sp.sympify(noise)
+            sympified_noise = sp.sympify(noise)
+            if sympified_noise is None \
+                    or (sympified_noise.is_Number
+                        and not sympified_noise.is_finite):
+                raise AssertionError(f"No or non-finite {NOISE_FORMULA} "
+                                     f"given for observable {row.Index}.")
         except sp.SympifyError as e:
             raise AssertionError(f"Cannot parse expression '{noise}' "
                                  f"for noise model for observable "


Test patch:
diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml
index 1c92a34..2aee552 100644
--- a/.github/workflows/ci_tests.yml
+++ b/.github/workflows/ci_tests.yml
@@ -11,7 +11,7 @@ jobs:
     strategy:
       matrix:
         platform: [windows-latest, macos-latest, ubuntu-latest]
-        python-version: [3.7, 3.8, 3.9, "3.10"]
+        python-version: ["3.7", "3.10"]
     runs-on: ${{ matrix.platform }}
 
     steps:
diff --git a/tests/test_lint.py b/tests/test_lint.py
index eccbed2..40f4c61 100644
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -495,6 +495,12 @@ def test_check_observable_df():
     with pytest.raises(AssertionError):
         lint.check_observable_df(bad_observable_df)
 
+    # Check that missing noiseFormula is detected
+    bad_observable_df = observable_df.copy()
+    bad_observable_df.loc['obs1', NOISE_FORMULA] = nan
+    with pytest.raises(AssertionError):
+        lint.check_observable_df(bad_observable_df)
+
 
 def test_condition_ids_are_unique():
     condition_df = pd.DataFrame(data={
Repository: PEtab-dev/libpetab-python

Issue:
no lint error for non-unique condition ids
`petab.lint.check_condition_df` does not check whether index entries are unique, but this is required according to documentation.

Comments:

Patch:
diff --git a/petab/lint.py b/petab/lint.py
index fe353ac..ba9ad8f 100644
--- a/petab/lint.py
+++ b/petab/lint.py
@@ -108,6 +108,10 @@ def check_condition_df(
 
     check_ids(df.index.values, kind='condition')
 
+    if not df.index.is_unique:
+        raise AssertionError("Non-unique condition IDs: "
+                             f"{df.index.values[df.index.duplicated()]}")
+
     for column_name in req_cols:
         if not np.issubdtype(df[column_name].dtype, np.number):
             assert_no_leading_trailing_whitespace(


Test patch:
diff --git a/tests/test_lint.py b/tests/test_lint.py
index 2756226..eccbed2 100644
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -494,3 +494,36 @@ def test_check_observable_df():
     bad_observable_df.index = ['obs1', 'obs1']
     with pytest.raises(AssertionError):
         lint.check_observable_df(bad_observable_df)
+
+
+def test_condition_ids_are_unique():
+    condition_df = pd.DataFrame(data={
+        CONDITION_ID: ['condition1', 'condition1'],
+        'parameter1': [1.0, 2.0]
+    })
+    condition_df.set_index(CONDITION_ID, inplace=True)
+
+    with pytest.raises(AssertionError):
+        lint.check_condition_df(condition_df)
+
+    condition_df.index = ['condition0', 'condition1']
+    condition_df.index.name = 'conditionId'
+    lint.check_condition_df(condition_df)
+
+
+def test_parameter_ids_are_unique():
+    parameter_df = pd.DataFrame({
+        PARAMETER_ID: ['par0', 'par0'],
+        PARAMETER_SCALE: [LIN, LIN],
+        ESTIMATE: [1, 1],
+        LOWER_BOUND: [1e-5, 1e-6],
+        UPPER_BOUND: [1e5, 1e6]
+
+    }).set_index(PARAMETER_ID)
+
+    with pytest.raises(AssertionError):
+        lint.check_parameter_df(parameter_df)
+
+    parameter_df.index = ['par0', 'par1']
+    parameter_df.index.name = 'parameterId'
+    lint.check_parameter_df(parameter_df)
Repository: PMEAL/OpenPNM

Issue:
Add the ability to delete hirarchical dictionary keys in one go
# Intended
```python
del geo['throat.conduit_lengths']  # this currently doesn't work
```
# Current
```python
del geo['throat.conduit_lengths.pore1']
del geo['throat.conduit_lengths.pore2']
del geo['throat.conduit_lengths.throat']
```

Comments:

Patch:
diff --git a/openpnm/core/Base.py b/openpnm/core/Base.py
index d1e2840ad..7b66f3993 100644
--- a/openpnm/core/Base.py
+++ b/openpnm/core/Base.py
@@ -251,6 +251,14 @@ class Base(dict):
             raise KeyError(key)
         return vals
 
+    def __delitem__(self, key):
+        try:
+            super().__delitem__(key)
+        except KeyError as e:
+            d = self[key]  # if key is a nested dict, get all values
+            for item in d.keys():
+                super().__delitem__(item)
+
     def _set_name(self, name, validate=True):
         old_name = self.settings['name']
         if name == old_name:


Test patch:
diff --git a/tests/unit/core/BaseTest.py b/tests/unit/core/BaseTest.py
index f82d99875..18ed0ae18 100644
--- a/tests/unit/core/BaseTest.py
+++ b/tests/unit/core/BaseTest.py
@@ -930,6 +930,19 @@ class BaseTest:
         with pytest.raises(KeyError):
             pn.get_conduit_data('blah')
 
+    def test_del_nested_dicts(self):
+        pn = op.network.Cubic(shape=[3, 3, 3])
+        geo = op.geometry.SpheresAndCylinders(network=pn,
+                                              pores=pn.Ps,
+                                              throats=pn.Ts)
+        assert 'throat.hydraulic_size_factors.pore1' in geo.keys()
+        del geo['throat.hydraulic_size_factors']
+        assert 'throat.hydraulic_size_factors.pore1' not in geo.keys()
+        with pytest.raises(KeyError):
+            geo['throat.hydraulic_size_factors']
+        with pytest.raises(KeyError):
+            del geo['pore.blah']
+
 
 if __name__ == '__main__':
Repository: PMEAL/porespy

Issue:
chunked_func should deal with funcs that return a result of different shape than the input
for instance, the convolve function can return an image wtih padding around the outside that breaks the chunking later on in the function

Comments:

Patch:
diff --git a/porespy/filters/__funcs__.py b/porespy/filters/__funcs__.py
index f24d97b24..d971f21b4 100644
--- a/porespy/filters/__funcs__.py
+++ b/porespy/filters/__funcs__.py
@@ -1712,11 +1712,8 @@ def chunked_func(func,
                 strel = kwargs[item]
                 break
         halo = np.array(strel.shape) * (divs > 1)
-    slices = np.ravel(
-        shape_split(
-            im.shape, axis=divs, halo=halo.tolist(), tile_bounds_policy=ARRAY_BOUNDS
-        )
-    )
+    slices = np.ravel(shape_split(im.shape, axis=divs, halo=halo.tolist(),
+                                  tile_bounds_policy=ARRAY_BOUNDS))
     # Apply func to each subsection of the image
     res = []
     # print('Image will be broken into the following chunks:')
@@ -1727,7 +1724,7 @@ def chunked_func(func,
         res.append(apply_func(func=func, **kwargs))
     # Have dask actually compute the function on each subsection in parallel
     # with ProgressBar():
-    #    ims = dask.compute(res, num_workers=cores)[0]
+        # ims = dask.compute(res, num_workers=cores)[0]
     ims = dask.compute(res, num_workers=cores)[0]
     # Finally, put the pieces back together into a single master image, im2
     im2 = np.zeros_like(im, dtype=im.dtype)
@@ -1752,7 +1749,11 @@ def chunked_func(func,
         a = tuple(a)
         b = tuple(b)
         # Insert image chunk into main image
-        im2[a] = ims[i][b]
+        try:
+            im2[a] = ims[i][b]
+        except ValueError:
+            raise IndexError('The applied filter seems to have returned a '
+                             + 'larger image that it was sent.')
     return im2
 
 


Test patch:
diff --git a/test/unit/test_filters.py b/test/unit/test_filters.py
index 47773ff69..07989d3f3 100644
--- a/test/unit/test_filters.py
+++ b/test/unit/test_filters.py
@@ -424,6 +424,16 @@ class FilterTest():
         b = ps.filters.fftmorphology(im, strel=s, mode='erosion')
         assert np.all(a == b)
 
+    def test_chunked_func_w_ill_defined_filter(self):
+        import scipy.signal as spsg
+        im = ps.generators.blobs(shape=[100, 100, 100])
+        with pytest.raises(IndexError):
+            ps.filters.chunked_func(func=spsg.convolve,
+                                    in1=im*1.0,
+                                    in2=ps.tools.ps_ball(5),
+                                    im_arg='in1', strel_arg='in2',
+                                    overlap=5)
+
     def test_prune_branches(self):
         im = ps.generators.lattice_spheres(shape=[100, 100, 100], radius=4)
         skel1 = skeletonize_3d(im)
Repository: PSLmodels/microdf

Issue:
Subsetting a MicroDataFrame doesn't subset weights
Example:
```
d = mdf.MicroDataFrame({"x": [1, 2, 3], "y": [1, 2, 2]}, weights=[4, 5, 6])
d2 = d[d.y > 1]
d2.shape  # (2, 2)
d2.weights.shape  # (3,)
```
Among other things, this breaks commands like `d[d.y > 1].mean()` with:
>TypeError: Axis must be specified when shapes of a and weights differ.

This doesn't affect MicroSeries:
```
s = mdf.MicroSeries([1, 2, 3], weights=[4, 5, 6])
s2 = s[s > 1]
s2.shape  # (2,)
s2.weights.shape  # (2,)
```

Comments:

Patch:
diff --git a/microdf/generic.py b/microdf/generic.py
index 4b31aba..b0906cf 100644
--- a/microdf/generic.py
+++ b/microdf/generic.py
@@ -373,6 +373,11 @@ class MicroSeries(pd.Series):
     def __pos__(self, other):
         return MicroSeries(super().__pos__(other), weights=self.weights)
 
+    def __repr__(self):
+        return pd.DataFrame(
+            dict(value=self.values, weight=self.weights.values)
+        ).__repr__()
+
 
 MicroSeries.SCALAR_FUNCTIONS = [
     fn
@@ -620,7 +625,10 @@ class MicroDataFrame(pd.DataFrame):
     def __getitem__(self, key):
         result = super().__getitem__(key)
         if isinstance(result, pd.DataFrame):
-            weights = self.weights
+            try:
+                weights = self.weights[key]
+            except Exception:
+                weights = self.weights
             return MicroDataFrame(result, weights=weights)
         return result
 
@@ -755,3 +763,8 @@ class MicroDataFrame(pd.DataFrame):
         """
         in_poverty = income < threshold
         return in_poverty.sum()
+
+    def __repr__(self):
+        df = pd.DataFrame(self)
+        df["weight"] = self.weights
+        return df[[df.columns[-1]] + list(df.columns[:-1])].__repr__()


Test patch:
diff --git a/microdf/tests/test_generic.py b/microdf/tests/test_generic.py
index 3dfaffa..3a1a58e 100644
--- a/microdf/tests/test_generic.py
+++ b/microdf/tests/test_generic.py
@@ -200,3 +200,9 @@ def test_subset():
     df_no_z_diff_weights = df_no_z.copy()
     df_no_z_diff_weights.weights += 1
     assert not df[["x", "y"]].equals(df_no_z_diff_weights)
+
+
+def test_value_subset():
+    d = mdf.MicroDataFrame({"x": [1, 2, 3], "y": [1, 2, 2]}, weights=[4, 5, 6])
+    d2 = d[d.y > 1]
+    assert d2.y.shape == d2.weights.shape
Repository: PennChopMicrobiomeProgram/illqc

Issue:
Cannot configure setting for sliding window
Python needs a tuple value for this setting, but JSON does not support tuple types.  Suggest converting to value tuple before line 70:

https://github.com/PennChopMicrobiomeProgram/illqc/blob/master/illqclib/main.py#L70

Comments:

Patch:
diff --git a/illqclib/main.py b/illqclib/main.py
index e8503bf..396d282 100644
--- a/illqclib/main.py
+++ b/illqclib/main.py
@@ -67,7 +67,7 @@ class Trimmomatic(object):
             "ILLUMINACLIP:%s:2:30:10:8:true" % self._adapter_fp,
             "LEADING:%d" % self.config["leading"],
             "TRAILING:%d" % self.config["trailing"],
-            "SLIDINGWINDOW:%d:%d" % self.config["slidingwindow"],
+            "SLIDINGWINDOW:%d:%d" % tuple(self.config["slidingwindow"]),
             "MINLEN:%d" % self.config["minlen"],
             ]
 


Test patch:
diff --git a/test/test_main.py b/test/test_main.py
index 7a75113..803ed7b 100644
--- a/test/test_main.py
+++ b/test/test_main.py
@@ -26,17 +26,19 @@ class ConfigTests(unittest.TestCase):
 
 
 class TrimmomaticTests(unittest.TestCase):
+    config_vals = {
+        "trimmomatic_jar_fp": "trimmomatic-0.30.jar",
+        "adapter_dir": "adapters",
+        "adapter": "NexteraPE-PE",
+        "leading": 3,
+        "trailing": 3,
+        "slidingwindow": (4, 15),
+        "minlen": 36,
+        "java_heapsize":"200M"
+    }
+
     def test_make_command(self):
-        app = Trimmomatic({
-            "trimmomatic_jar_fp": "trimmomatic-0.30.jar",
-            "adapter_dir": "adapters",
-            "adapter": "NexteraPE-PE",
-            "leading": 3,
-            "trailing": 3,
-            "slidingwindow": (4, 15),
-            "minlen": 36,
-	    "java_heapsize":"200M"
-            })
+        app = Trimmomatic(self.config_vals)
         observed = app.make_command("a.fastq", "b.fastq", "mydir")
         expected = [
             'java', '-Xmx200M', '-jar', 'trimmomatic-0.30.jar', 'PE', '-phred33',
@@ -47,3 +49,18 @@ class TrimmomaticTests(unittest.TestCase):
             'LEADING:3', 'TRAILING:3', 'SLIDINGWINDOW:4:15', 'MINLEN:36',
             ]
         self.assertEqual(observed, expected)
+
+    def test_make_command_sliding_window_as_list(self):
+        config_vals = self.config_vals.copy()
+        config_vals["slidingwindow"] = [6, 32]
+        app = Trimmomatic(config_vals)
+        observed = app.make_command("a.fastq", "b.fastq", "mydir")
+        expected = [
+            'java', '-Xmx200M', '-jar', 'trimmomatic-0.30.jar', 'PE', '-phred33',
+            'a.fastq', 'b.fastq',
+            'mydir/a.fastq', 'mydir/a_unpaired.fastq',
+            'mydir/b.fastq', 'mydir/b_unpaired.fastq',
+            'ILLUMINACLIP:adapters/NexteraPE-PE.fa:2:30:10:8:true',
+            'LEADING:3', 'TRAILING:3', 'SLIDINGWINDOW:6:32', 'MINLEN:36',
+            ]
+        self.assertEqual(observed, expected)