nebius/SWE-bench-extra huggingface dataset:
Repository: mherrmann/gitignore_parser

Issue:
Bug with matching paths within .gitignore directory
Is this correct? It feels like a bug to me since it works when you specify the rule in `.gitignore`.


Imagine `.gitignore` contents including

```
.venv/
```


And a script evaluating this

```
gitignore_matcher('/path/to/repo/.venv/')
True
gitignore_matcher('/path/to/repo/.venv/bin')
False
```

To me the second one should return `True`

Comments:

Patch:
diff --git a/gitignore_parser.py b/gitignore_parser.py
index c8a7771..5ce75f8 100644
--- a/gitignore_parser.py
+++ b/gitignore_parser.py
@@ -102,7 +102,7 @@ def rule_from_pattern(pattern, base_path=None, source=None):
 			if striptrailingspaces:
 				pattern = pattern[:i]
 		i = i - 1
-	regex = fnmatch_pathname_to_regex(pattern)
+	regex = fnmatch_pathname_to_regex(pattern, directory_only)
 	if anchored:
 		regex = ''.join(['^', regex])
 	return IgnoreRule(
@@ -147,7 +147,7 @@ class IgnoreRule(collections.namedtuple('IgnoreRule_', IGNORE_RULE_FIELDS)):
 
 # Frustratingly, python's fnmatch doesn't provide the FNM_PATHNAME
 # option that .gitignore's behavior depends on.
-def fnmatch_pathname_to_regex(pattern):
+def fnmatch_pathname_to_regex(pattern, directory_only: bool):
 	"""
 	Implements fnmatch style-behavior, as though with FNM_PATHNAME flagged;
 	the path separator will not match shell-style '*' and '.' wildcards.
@@ -201,5 +201,6 @@ def fnmatch_pathname_to_regex(pattern):
 		else:
 			res.append(re.escape(c))
 	res.insert(0, '(?ms)')
-	res.append('$')
-	return ''.join(res)
\ No newline at end of file
+	if not directory_only:
+		res.append('$')
+	return ''.join(res)


Test patch:
diff --git a/tests.py b/tests.py
index 6b28b64..c1b6aad 100644
--- a/tests.py
+++ b/tests.py
@@ -74,6 +74,18 @@ class Test(TestCase):
 		self.assertTrue(matches('/home/michael/othermatch'))
 		self.assertTrue(matches('/home/michael/#imnocomment'))
 
+	def test_ignore_directory(self):
+		matches = _parse_gitignore_string('.venv/', fake_base_dir='/home/michael')
+		self.assertTrue(matches('/home/michael/.venv'))
+		self.assertTrue(matches('/home/michael/.venv/folder'))
+		self.assertTrue(matches('/home/michael/.venv/file.txt'))
+
+	def test_ignore_directory_astrix(self):
+		matches = _parse_gitignore_string('.venv/*', fake_base_dir='/home/michael')
+		self.assertFalse(matches('/home/michael/.venv'))
+		self.assertTrue(matches('/home/michael/.venv/folder'))
+		self.assertTrue(matches('/home/michael/.venv/file.txt'))
+
 	def test_negation(self):
 		matches = _parse_gitignore_string(
 			'''
Repository: mhostetter/galois

Issue:
galois.is_irreducible(poly) seems to return some false negatives in large odd exponent GFs
Hi Matt, hope all is well.

Even though it works fine for other groups (e.g. even groups likes GF(2^256) work well), still I 've been getting the following false negative result when using the galois.is_irreducible(poly) over odd groups tο produce irreducible polynomials over GF(2^233). 

For example, we know from previous publications and research that x^233+x^74+1 is irreducible over GF(2) for creating the quotient ring of GF(2^233) but the following code returns Null for every polynomial (including the aforementioned one):
```
def loop_init_trinomial():
    #initial detection loop
    for k in range(1, 233):
        poly = galois.Poly.Degrees([233, k, 0])
        if galois.is_irreducible(poly):
            print("Found one: ", k, poly, poly.string)
```
Care to share some thoughts?

Comments:

Patch:
diff --git a/galois/_polys/_poly.py b/galois/_polys/_poly.py
index 182703a7d..3d7c9bf76 100644
--- a/galois/_polys/_poly.py
+++ b/galois/_polys/_poly.py
@@ -1513,7 +1513,7 @@ class Poly:
                 if self._nonzero_degrees.size == 0:
                     self._degree = 0
                 else:
-                    self._degree = max(self._nonzero_degrees)
+                    self._degree = int(max(self._nonzero_degrees))
             elif hasattr(self, "_integer"):
                 if self._integer == 0:
                     self._degree = 0


Test patch:
diff --git a/tests/polys/test_irreducible_polys.py b/tests/polys/test_irreducible_polys.py
index f3aefef69..de10d0934 100644
--- a/tests/polys/test_irreducible_polys.py
+++ b/tests/polys/test_irreducible_polys.py
@@ -111,3 +111,11 @@ def test_irreducible_polys_exceptions():
 def test_irreducible_polys(order, degree):
     LUT = eval(f"IRREDUCIBLE_POLYS_{order}_{degree}")
     assert [f.coeffs.tolist() for f in galois.irreducible_polys(order, degree)] == LUT
+
+
+def test_large_degree():
+    """
+    See https://github.com/mhostetter/galois/issues/360.
+    """
+    f = galois.Poly.Degrees([233, 74, 0])
+    assert galois.is_irreducible(f)
Repository: microsoft/torchgeo

Issue:
VectorDataset incorrect sample shape 
### Description

Querying a sample from a VectorDataset object returns (sometimes?) a mask with incorrect shape.

This is caused by not rounding the calculated width and height pixel values to the nearest integer, and just taking the `int(width)` and `int(height)` values instead for `masks = rasterio.features.rasterize` in [torchgeo.datasets.geo.py:614](https://github.com/microsoft/torchgeo/blob/b41b6d68f99edfbe4d82b31f6f9b16cbd33f485e/torchgeo/datasets/geo.py#L614).

### Steps to reproduce

Run the following code to reproduce the error:
```
from torchgeo.datasets import CanadianBuildingFootprints
from torchgeo.samplers import RandomGeoSampler

cbf_dataset = CanadianBuildingFootprints(download=True)  # or any other VectorDataset-based dataset

size = 512

sampler = RandomGeoSampler(cbf_dataset, size=size, length=100)  # or any other sampler
query = next(iter(sampler))

sample = cbf_dataset[query]

print(sample["mask"].shape)
assert sample["mask"].shape[0] == size, sample["mask"].shape
assert sample["mask"].shape[1] == size, sample["mask"].shape
```

### Version

0.3.0

Comments:

Patch:
diff --git a/requirements/required.txt b/requirements/required.txt
index 8dadad11..49c7199c 100644
--- a/requirements/required.txt
+++ b/requirements/required.txt
@@ -1,10 +1,10 @@
 # setup
-setuptools==63.1.0
+setuptools==63.2.0
 
 # install
 einops==0.4.1
 fiona==1.9a2
-kornia==0.6.5
+kornia==0.6.6
 matplotlib==3.5.2
 numpy==1.23.1;python_version>='3.8'
 omegaconf==2.2.2
diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py
index c74833d8..07900368 100644
--- a/torchgeo/datasets/geo.py
+++ b/torchgeo/datasets/geo.py
@@ -611,12 +611,12 @@ class VectorDataset(GeoDataset):
         )
         if shapes:
             masks = rasterio.features.rasterize(
-                shapes, out_shape=(int(height), int(width)), transform=transform
+                shapes, out_shape=(round(height), round(width)), transform=transform
             )
         else:
             # If no features are found in this query, return an empty mask
             # with the default fill value and dtype used by rasterize
-            masks = np.zeros((int(height), int(width)), dtype=np.uint8)
+            masks = np.zeros((round(height), round(width)), dtype=np.uint8)
 
         sample = {"mask": torch.tensor(masks), "crs": self.crs, "bbox": query}
 


Test patch:
diff --git a/tests/datasets/test_geo.py b/tests/datasets/test_geo.py
index 5742134d..5abb7766 100644
--- a/tests/datasets/test_geo.py
+++ b/tests/datasets/test_geo.py
@@ -223,7 +223,7 @@ class TestVectorDataset:
     def test_empty_shapes(self, dataset: CustomVectorDataset) -> None:
         query = BoundingBox(1.1, 1.9, 1.1, 1.9, 0, 0)
         x = dataset[query]
-        assert torch.equal(x["mask"], torch.zeros(7, 7, dtype=torch.uint8))
+        assert torch.equal(x["mask"], torch.zeros(8, 8, dtype=torch.uint8))
 
     def test_invalid_query(self, dataset: CustomVectorDataset) -> None:
         query = BoundingBox(3, 3, 3, 3, 0, 0)
Repository: mie-lab/trackintel

Issue:
Bug in location_identifier for pre_filter=False and non-serial index
The function [location_identifier](https://github.com/mie-lab/trackintel/blob/master/trackintel/analysis/location_identification.py#L7) assumes that an index is serial e.g., incremental from 0 to n. It throws an error in fthe index is not serial and sorts the dataframe (may not be intended) if the index is serial but not in order.

The problem is that for `pre_filter=False` [here](https://github.com/mie-lab/trackintel/blob/master/trackintel/analysis/location_identification.py#L65) a boolean series with the same length as the staypoint dataframe and serial index is created. 

From the geopandas documentation for what can be input to `loc` for indexing: 
_An alignable boolean Series. The index of the key will be aligned before masking._ [source](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.loc.html)

A fix could be to either use the original index when creating `f` in line [65](https://github.com/mie-lab/trackintel/blob/master/trackintel/analysis/location_identification.py#L65), to use a boolean array without index or to use iloc instead of loc.




Comments:

Patch:
diff --git a/trackintel/analysis/location_identification.py b/trackintel/analysis/location_identification.py
index 33e691c..6682e4a 100644
--- a/trackintel/analysis/location_identification.py
+++ b/trackintel/analysis/location_identification.py
@@ -62,7 +62,7 @@ def location_identifier(staypoints, method="FREQ", pre_filter=True, **pre_filter
     if pre_filter:
         f = pre_filter_locations(sp, **pre_filter_kwargs)
     else:
-        f = pd.Series(np.full(len(sp.index), True))
+        f = pd.Series(np.full(len(sp.index), True), index=sp.index)
 
     if method == "FREQ":
         method_val = freq_method(sp[f], "home", "work")


Test patch:
diff --git a/tests/analysis/test_location_identification.py b/tests/analysis/test_location_identification.py
index a256ca5..af0917c 100644
--- a/tests/analysis/test_location_identification.py
+++ b/tests/analysis/test_location_identification.py
@@ -253,6 +253,15 @@ class TestLocation_Identifier:
         osna = osna_method(example_osna)
         assert_geodataframe_equal(li, osna)
 
+    def test_pre_filter_index(self, example_freq):
+        """Test if pre_filter=False works with non-serial index"""
+        # issue-#403
+        example_freq.index = *reversed(example_freq.index[1:]), example_freq.index[0]
+        example_freq.index += 100  # move it so that there is no overlap to a range index
+        li = location_identifier(example_freq, method="FREQ", pre_filter=False)
+        fr = freq_method(example_freq)
+        assert_geodataframe_equal(li, fr)
+
 
 @pytest.fixture
 def example_osna():
Repository: mie-lab/trackintel

Issue:
Raise error in gpx reader if path does not exist
We had a problem that the gpx reader function still executed even though the path did not exist, and then an error was only thrown in the last line `pd.concat(pfs_list, ignore_index=True)` with the error `no objects to concatenate`. There should be an error `Path does not exist` or so

Comments:

Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c816663..ed07d36 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ ci:
 
 repos: 
 - repo: https://github.com/psf/black 
-  rev: 23.10.1 
+  rev: 23.11.0 
   hooks:
   - id: black
     args: [
diff --git a/trackintel/io/dataset_reader.py b/trackintel/io/dataset_reader.py
index 25c4cc3..c2c6b2a 100644
--- a/trackintel/io/dataset_reader.py
+++ b/trackintel/io/dataset_reader.py
@@ -700,10 +700,13 @@ def read_gpx(path):
     Positionfixes
     """
     pattern = os.path.join(path, "*.gpx")
+    # sorted to make result deterministic
+    files = sorted(glob.glob(pattern))
+    if not files:
+        raise FileNotFoundError(f'Found no gpx files in path "{path}"')
     pfs_list = []
     track_fid_offset = 0
-    # sorted to make result deterministic
-    for file in sorted(glob.glob(pattern)):
+    for file in files:
         pfs = _read_single_gpx_file(file)
         # give each track an unique ID
         pfs["track_fid"] += track_fid_offset


Test patch:
diff --git a/tests/io/test_dataset_reader.py b/tests/io/test_dataset_reader.py
index d963554..577d7c8 100644
--- a/tests/io/test_dataset_reader.py
+++ b/tests/io/test_dataset_reader.py
@@ -268,3 +268,8 @@ class TestGpx_reader:
         }
         pfs_test = Positionfixes(data, geometry="geometry", crs=4326)
         assert_geodataframe_equal(pfs, pfs_test)
+
+    def test_missing_files(self):
+        """Test if useful message is output if directory has no gpx files"""
+        with pytest.raises(FileNotFoundError, match="Found no gpx files"):
+            read_gpx(os.path.join("tests", "data"))