nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: vmware/govmomi
Pull request #3034 (2023-01-24 02:25:28)

vcsim: add guest.net.ipConfig
## Description

This is needed to support the VirtualMachine.WaitForNetIP helper against vcsim

## Type of change

Please mark options that are relevant:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to
  not work as expected)
- [ ] This change requires a documentation update
- [ ] Build related change

## How Has This Been Tested?

Added tests to vcsim.bats that cover `VirtualMachine.WaitForIP()`

## Checklist:

- [x] My code follows the `CONTRIBUTION`
  [guidelines](https://github.com/vmware/govmomi/blob/main/CONTRIBUTING.md) of
  this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged


Patch:
diff --git a/simulator/container.go b/simulator/container.go
index 08f8f7ed..96f4fd10 100644
--- a/simulator/container.go
+++ b/simulator/container.go
@@ -114,6 +114,20 @@ func (c *container) inspect(vm *VirtualMachine) error {
 			net := &vm.Guest.Net[0]
 			net.IpAddress = []string{s.IPAddress}
 			net.MacAddress = s.MacAddress
+			net.IpConfig = &types.NetIpConfigInfo{
+				IpAddress: []types.NetIpConfigInfoIpAddress{{
+					IpAddress:    s.IPAddress,
+					PrefixLength: int32(s.IPPrefixLen),
+					State:        string(types.NetIpConfigInfoIpAddressStatusPreferred),
+				}},
+			}
+		}
+
+		for _, d := range vm.Config.Hardware.Device {
+			if eth, ok := d.(types.BaseVirtualEthernetCard); ok {
+				eth.GetVirtualEthernetCard().MacAddress = s.MacAddress
+				break
+			}
 		}
 	}
 


Test patch:
diff --git a/govc/test/vcsim.bats b/govc/test/vcsim.bats
index 735ef741..3ca249d1 100755
--- a/govc/test/vcsim.bats
+++ b/govc/test/vcsim.bats
@@ -267,6 +267,15 @@ EOF
   netip=$(govc object.collect -json -o vm/$vm guest.net | jq -r .Guest.net[].ipAddress[0])
   [ "$netip" = "$ip" ]
 
+  run govc vm.ip $vm # covers VirtualMachine.WaitForIP
+  assert_success "$ip"
+
+  run govc vm.ip -a $vm # covers VirtualMachine.WaitForNetIP
+  assert_success "$ip"
+
+  run govc vm.ip -n ethernet-0 $vm # covers VirtualMachine.WaitForNetIP
+  assert_success "$ip"
+
   run govc vm.power -s $vm
   assert_success
Repository: Ouranosinc/xclim
Pull request #55 (2018-10-03 19:21:06)

Rx1day update
Added strict nan behavior : a single nan in a given period will result in a nan rx1day value.  Note nan presence triggers a warning from the reduce() method as well indicating there are non-valid values...  


Patch:
diff --git a/README.rst b/README.rst
index a55a7a58..4707f890 100644
--- a/README.rst
+++ b/README.rst
@@ -24,6 +24,10 @@ xclim
         :target: https://www.codefactor.io/repository/github/ouranosinc/xclim
         :alt: CodeFactor
 
+.. image:: https://www.codefactor.io/repository/github/ouranosinc/xclim/badge
+   :target: https://www.codefactor.io/repository/github/ouranosinc/xclim
+   :alt: CodeFactor
+
 .. image:: https://readthedocs.org/projects/xclim/badge/?version=latest
         :target: https://xclim.readthedocs.io/en/latest/?badge=latest
         :alt: Documentation Status
diff --git a/xclim/indices.py b/xclim/indices.py
index fd225935..fd0c4e05 100644
--- a/xclim/indices.py
+++ b/xclim/indices.py
@@ -664,7 +664,7 @@ def tn_min(tasmin, freq='YS'):
 
 # @check_daily_monotonic # TODO create daily timestep check
 # @convert_precip_units   # TODO create units checker / converter
-def max_1day_precipitation_amount(da, freq='YS'):
+def max_1day_precipitation_amount(da, freq='YS', skipna=False):
     """Highest 1-day precipitation amount for a period (frequency).
 
     Resample the original daily total precipitaiton temperature series by taking the max over each period.
@@ -700,7 +700,7 @@ def max_1day_precipitation_amount(da, freq='YS'):
 
     # use custom resample function for now
     grouper = dds(da, freq=freq)
-    output = grouper.max(dim='time', keep_attrs=True)
+    output = grouper.max(dim='time', keep_attrs=True, skipna=skipna)
 
     # add time coords to output and change dimension tags to time
     time1 = dds(da.time, freq=freq).first()


Test patch:
diff --git a/tests/test_indices.py b/tests/test_indices.py
index 6ebf60c9..acb07628 100644
--- a/tests/test_indices.py
+++ b/tests/test_indices.py
@@ -67,6 +67,12 @@ class Test_max_1day_precipitation_amount():
         assert rx1day.time.dt.year == 2000
         assert len(rx1day) == 1
 
+    # test nan behavior
+    def test_nan_max(self):
+        a = self.time_series(np.array([20, np.nan, 20, 20, 0]))
+        rx1day = xci.max_1day_precipitation_amount(a)
+        assert np.isnan(rx1day)
+
 
 class Test_consecutive_frost_days():
     def time_series(self, values):
Repository: CS-SI/eodag
Pull request #1410 (2024-11-20 16:38:54)

feat(core): add to_lower and to_upper parameters mapping
Adds `to_lower` and `to_upper` methods as parameters mapping converters

### Your checklist for this pull request
Please review the [guidelines for contributing](../CONTRIBUTING.md) to this repository.

- [X] Make sure you are making a pull request against the **develop branch** (left side). Also you should start *your branch* off *our develop*.
- [X] Check the commit's or even all commits' message styles matches our requested structure.
- [X] Check your code additions will fail neither code linting checks nor unit test.

### Description
Add the`to_lower` and `to_upper` converters to parameters mapping: https://github.com/CS-SI/eodag/blob/eeb8d3b01c42fbd4d97aef28d3410e257378281a/docs/params_mapping.rst


Patch:
diff --git a/eodag/api/product/metadata_mapping.py b/eodag/api/product/metadata_mapping.py
index 4c4d3866..da14e0ed 100644
--- a/eodag/api/product/metadata_mapping.py
+++ b/eodag/api/product/metadata_mapping.py
@@ -179,6 +179,8 @@ def format_metadata(search_param: str, *args: Any, **kwargs: Any) -> str:
         - ``recursive_sub_str``: recursively substitue in the structure (e.g. dict)
           values matching a regex
         - ``slice_str``: slice a string (equivalent to s[start, end, step])
+        - ``to_lower``: Convert a string to lowercase
+        - ``to_upper``: Convert a string to uppercase
         - ``fake_l2a_title_from_l1c``: used to generate SAFE format metadata for data from AWS
         - ``s2msil2a_title_to_aws_productinfo``: used to generate SAFE format metadata for data from AWS
         - ``split_cop_dem_id``: get the bbox by splitting the product id
@@ -558,6 +560,16 @@ def format_metadata(search_param: str, *args: Any, **kwargs: Any) -> str:
             ]
             return string[cmin:cmax:cstep]
 
+        @staticmethod
+        def convert_to_lower(string: str) -> str:
+            """Convert a string to lowercase."""
+            return string.lower()
+
+        @staticmethod
+        def convert_to_upper(string: str) -> str:
+            """Convert a string to uppercase."""
+            return string.upper()
+
         @staticmethod
         def convert_fake_l2a_title_from_l1c(string: str) -> str:
             id_regex = re.compile(


Test patch:
diff --git a/tests/units/test_metadata_mapping.py b/tests/units/test_metadata_mapping.py
index 63ae1183..658595ba 100644
--- a/tests/units/test_metadata_mapping.py
+++ b/tests/units/test_metadata_mapping.py
@@ -262,6 +262,14 @@ class TestMetadataFormatter(unittest.TestCase):
             "bdfhjl",
         )
 
+    def test_convert_to_lower(self):
+        to_format = r"{fieldname#to_lower}"
+        self.assertEqual(format_metadata(to_format, fieldname="FoO.bAr"), "foo.bar")
+
+    def test_convert_to_upper(self):
+        to_format = r"{fieldname#to_upper}"
+        self.assertEqual(format_metadata(to_format, fieldname="FoO.bAr"), "FOO.BAR")
+
     def test_convert_fake_l2a_title_from_l1c(self):
         to_format = "{fieldname#fake_l2a_title_from_l1c}"
         self.assertEqual(
Repository: ResearchObject/ro-crate-py
Pull request #67 (2021-05-21 11:14:22)

Add new `write-zip` command to CLI
This PR exposes the `write_zip` API function through the CLI


Patch:
diff --git a/rocrate/cli.py b/rocrate/cli.py
index df6369b..7512383 100644
--- a/rocrate/cli.py
+++ b/rocrate/cli.py
@@ -122,5 +122,14 @@ def definition(state, suite, path, engine, engine_version):
     state.crate.metadata.write(crate_dir)
 
 
+@cli.command()
+@click.argument('dst', type=click.Path(writable=True))
+@click.pass_obj
+def write_zip(state, dst):
+    crate_dir = state.crate_dir or os.getcwd()
+    crate = ROCrate(crate_dir, init=True, gen_preview=False)
+    crate.write_zip(dst)
+
+
 if __name__ == '__main__':
     cli()


Test patch:
diff --git a/test/test_cli.py b/test/test_cli.py
index da631ec..9073893 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -130,3 +130,23 @@ def test_cli_add_test_metadata(test_data_dir, helpers, monkeypatch, cwd):
     assert len(context) > 1
     extra_terms = context[1]
     assert set(TESTING_EXTRA_TERMS.items()).issubset(extra_terms.items())
+
+
+@pytest.mark.parametrize("cwd", [False, True])
+def test_cli_write_zip(test_data_dir, monkeypatch, cwd):
+    crate_dir = test_data_dir / "ro-crate-galaxy-sortchangecase"
+    runner = CliRunner()
+    assert runner.invoke(cli, ["-c", str(crate_dir), "init"]).exit_code == 0
+
+    output_zip_path = test_data_dir / "test-zip-archive.zip"
+    args = []
+    if cwd:
+        monkeypatch.chdir(str(crate_dir))
+    else:
+        args.extend(["-c", str(crate_dir)])
+    args.append("write-zip")
+    args.append(str(output_zip_path))
+
+    result = runner.invoke(cli, args)
+    assert result.exit_code == 0
+    assert output_zip_path.is_file()
Repository: ResearchObject/ro-crate-py
Pull request #124 (2022-05-10 10:26:25)

Fix default workflow types initialization
In `ComputationalWorkflow`, the default type list is a reference to the class variable:

```python
TYPES = ["File", "SoftwareSourceCode", "ComputationalWorkflow"]
```

This leads to weird behavior when multiple `ComputationalWorkflow` instances are created, even in different crates:

```python
crate1 = ROCrate()
wf1 = crate1.add_workflow("foo.cwl", main=True)
wf1.type.append("HowTo")
crate2 = ROCrate()
wf2 = crate2.add_workflow("bar.cwl")
print(wf2.type)
```

```
['File', 'SoftwareSourceCode', 'ComputationalWorkflow', 'HowTo']
```

This PR fixes the problem by initializing the types with a _copy_ of the class-level type list.


Patch:
diff --git a/rocrate/model/computationalworkflow.py b/rocrate/model/computationalworkflow.py
index 51e7b4a..f1bf833 100644
--- a/rocrate/model/computationalworkflow.py
+++ b/rocrate/model/computationalworkflow.py
@@ -37,7 +37,7 @@ class ComputationalWorkflow(File):
     def _empty(self):
         return {
             "@id": self.id,
-            "@type": self.TYPES,
+            "@type": self.TYPES[:],
             "name": os.path.splitext(self.id)[0],
         }
 


Test patch:
diff --git a/test/test_model.py b/test/test_model.py
index 2501c65..642a762 100644
--- a/test/test_model.py
+++ b/test/test_model.py
@@ -393,3 +393,13 @@ def test_entity_as_mapping(tmpdir, helpers):
     }
     with pytest.raises(ValueError):
         correction["badProp"]
+
+
+def test_wf_types():
+    foo_crate = ROCrate()
+    foo_wf = foo_crate.add_workflow("foo.cwl", main=True)
+    assert "HowTo" not in foo_wf.type
+    foo_wf.type.append("HowTo")
+    bar_crate = ROCrate()
+    bar_wf = bar_crate.add_workflow("bar.cwl", main=True)
+    assert "HowTo" not in bar_wf.type
Repository: ResearchObject/ro-crate-py
Pull request #154 (2023-06-09 13:17:26)

Handle CWL versions with a leading v
So that `https://w3id.org/cwl/v1.2/` is generated both if the supplied version was `1.2` and `v1.2`.


Patch:
diff --git a/rocrate/model/computerlanguage.py b/rocrate/model/computerlanguage.py
index 014bdc0..718e23d 100644
--- a/rocrate/model/computerlanguage.py
+++ b/rocrate/model/computerlanguage.py
@@ -77,7 +77,7 @@ def cwl(crate, version=None):
     id_ = "https://w3id.org/workflowhub/workflow-ro-crate#cwl"
     identifier = "https://w3id.org/cwl/"
     if version:
-        identifier = f"{identifier}v{version}/"
+        identifier = f"{identifier}v{version.lstrip('v')}/"
     properties = {
         "name": "Common Workflow Language",
         "alternateName": "CWL",


Test patch:
diff --git a/test/test_workflow_ro_crate.py b/test/test_workflow_ro_crate.py
index 6deed65..08f5e7b 100644
--- a/test/test_workflow_ro_crate.py
+++ b/test/test_workflow_ro_crate.py
@@ -127,7 +127,7 @@ def test_create_wf_include(test_data_dir, tmpdir, helpers):
         assert f1.read() == f2.read()
 
 
-@pytest.mark.parametrize("lang_version", [None, "1.2"])
+@pytest.mark.parametrize("lang_version", [None, "1.2", "v1.2"])
 def test_cwl_lang_version(test_data_dir, lang_version):
     wf_id = 'sample_cwl_wf.cwl'
     wf_path = test_data_dir / wf_id
@@ -138,6 +138,9 @@ def test_cwl_lang_version(test_data_dir, lang_version):
     if lang_version is None:
         assert lang_id == "https://w3id.org/cwl/"
         assert "version" not in lang
-    else:
+    elif lang_version == "1.2":
         assert lang_id == "https://w3id.org/cwl/v1.2/"
         assert lang["version"] == "1.2"
+    else:
+        assert lang_id == "https://w3id.org/cwl/v1.2/"
+        assert lang["version"] == "v1.2"
Repository: ResearchObject/ro-crate-py
Pull request #208 (2024-12-09 15:04:49)

Fix dataset id when adding a local dir with trailing slash
See https://github.com/ResearchObject/ro-crate-py/issues/206#issuecomment-2520523621

Minimally:

```pycon
>>> from rocrate.rocrate import ROCrate
>>> crate = ROCrate()
>>> folder = crate.add_dataset("folder/")
>>> folder.id
'#7e28c8e2-54ef-4c2e-af09-3bcbaaa986e3'
```


Patch:
diff --git a/rocrate/model/file_or_dir.py b/rocrate/model/file_or_dir.py
index 5f192f0..4b37509 100644
--- a/rocrate/model/file_or_dir.py
+++ b/rocrate/model/file_or_dir.py
@@ -47,5 +47,5 @@ class FileOrDir(DataEntity):
             if is_url(str(source)):
                 identifier = os.path.basename(source) if fetch_remote else source
             else:
-                identifier = "./" if source == "./" else os.path.basename(source)
+                identifier = os.path.basename(str(source).rstrip("/"))
         super().__init__(crate, identifier, properties)


Test patch:
diff --git a/test/test_model.py b/test/test_model.py
index 7835500..ad69283 100644
--- a/test/test_model.py
+++ b/test/test_model.py
@@ -41,7 +41,7 @@ from rocrate.model import (
 RAW_REPO_URL = "https://raw.githubusercontent.com/ResearchObject/ro-crate-py"
 
 
-def test_dereferencing(test_data_dir, helpers):
+def test_dereferencing(test_data_dir, helpers, monkeypatch):
     crate = ROCrate(gen_preview=True)
 
     # verify default entities
@@ -69,6 +69,12 @@ def test_dereferencing(test_data_dir, helpers):
     # alias
     assert crate.get(readme_url) is readme_entity
 
+    # dereference local dir added with trailing slash
+    monkeypatch.chdir(test_data_dir)
+    local_dir = "test_add_dir/"
+    local_dir_entity = crate.add_dataset(local_dir)
+    assert crate.dereference(local_dir) is local_dir_entity
+
 
 @pytest.mark.parametrize("name", [".foo", "foo.", ".foo/", "foo./"])
 def test_dereferencing_equivalent_id(test_data_dir, name):
Repository: ResearchObject/ro-crate-py
Pull request #214 (2025-02-28 08:45:37)

fix: Error message for incompatible constructor options
The constructor arguments `init` and passing a jsonld dictionary as source are mutually exclusive.

At the moment, when passing a `dict` containing JSONLD as source to the contructor and setting `init=True`, a cryptic error message is shown:

```python
from rocrate.rocrate import ROCrate
crate = ROCrate({"@context": "http://example.com", "@graph": []}, init=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dbauer/projects/ro-crate-py/rocrate/rocrate.py", line 94, in __init__
    self.__init_from_tree(source, gen_preview=gen_preview)
  File "/home/dbauer/projects/ro-crate-py/rocrate/rocrate.py", line 101, in __init_from_tree
    top_dir = Path(top_dir)
  File "/home/dbauer/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/pathlib.py", line 1082, in __new__
    self = cls._from_parts(args, init=False)
  File "/home/dbauer/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/pathlib.py", line 707, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/home/dbauer/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/pathlib.py", line 691, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not dict
```

This PR replaces this error with a message telling the user what the issue actually is:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dbauer/projects/ro-crate-py/rocrate/rocrate.py", line 95, in __init__
    raise ValueError("parameter init is not compatible with a JsonLD source")
ValueError: parameter init is not compatible with a JsonLD source
```


Patch:
diff --git a/rocrate/rocrate.py b/rocrate/rocrate.py
index 5d78be0..906dcf5 100644
--- a/rocrate/rocrate.py
+++ b/rocrate/rocrate.py
@@ -91,6 +91,8 @@ class ROCrate():
             # create a new ro-crate
             self.add(RootDataset(self), Metadata(self))
         elif init:
+            if isinstance(source, dict):
+                raise ValueError("parameter 'init' is not compatible with a dict source")
             self.__init_from_tree(source, gen_preview=gen_preview)
         else:
             source = self.__read(source, gen_preview=gen_preview)


Test patch:
diff --git a/test/test_read.py b/test/test_read.py
index 7c70333..2eaa0ac 100644
--- a/test/test_read.py
+++ b/test/test_read.py
@@ -595,3 +595,5 @@ def test_from_dict(tmpdir):
     for entity in d1, d2, f1:
         entity.source = None
     crate.write(out_path)
+    with pytest.raises(ValueError):
+        ROCrate(metadata, init=True)