nebius/SWE-bench-extra huggingface dataset:
Repository: fatiando/boule

Issue:
Check if normal gravity is computed on internal point
**Description of the desired feature**

The normal gravity formulas used on `boule.Ellipsoid.normal_gravity()` and `boule.Sphere.normal_gravity()` are valid only for points outside the ellipsoid.
Would be nice to add a warning in case the given point falls inside it.
To do so we just need to check if the `height` is positive or equal to zero.

**Are you willing to help implement and maintain this feature?** Yes, but would be glad to help anyone who wants to implement it.

<!--
Every feature we add is code that we will have to maintain and keep updated.
This takes a lot of effort. If you are willing to be involved in the project
and help maintain your feature, it will make it easier for us to accept it.
-->


Comments:

Patch:
diff --git a/boule/ellipsoid.py b/boule/ellipsoid.py
index b75498b..a71cf6a 100644
--- a/boule/ellipsoid.py
+++ b/boule/ellipsoid.py
@@ -453,6 +453,13 @@ class Ellipsoid:
             The normal gravity in mGal.
 
         """
+        # Warn if height is negative
+        if np.any(height < 0):
+            warn(
+                "Formulas used are valid for points outside the ellipsoid."
+                "Height must be greater than or equal to zero."
+            )
+
         sinlat = np.sin(np.deg2rad(latitude))
         coslat = np.sqrt(1 - sinlat ** 2)
         # The terms below follow the variable names from Li and Goetze (2001)
diff --git a/boule/sphere.py b/boule/sphere.py
index 15e8ea7..895cadd 100644
--- a/boule/sphere.py
+++ b/boule/sphere.py
@@ -193,6 +193,12 @@ class Sphere(Ellipsoid):
             The normal gravity in mGal.
 
         """
+        # Warn if height is negative
+        if np.any(height < 0):
+            warn(
+                "Formulas used are valid for points outside the ellipsoid."
+                "Height must be greater than or equal to zero."
+            )
         radial_distance = self.radius + height
         gravity_acceleration = self.geocentric_grav_const / (radial_distance) ** 2
         gamma = np.sqrt(


Test patch:
diff --git a/boule/tests/test_ellipsoid.py b/boule/tests/test_ellipsoid.py
index b509f43..e96dabf 100644
--- a/boule/tests/test_ellipsoid.py
+++ b/boule/tests/test_ellipsoid.py
@@ -325,3 +325,14 @@ def test_normal_gravity_against_somigliana(ellipsoid):
             ellipsoid.normal_gravity(latitude, height=0),
             normal_gravity_surface(latitude, ellipsoid),
         )
+
+
+@pytest.mark.parametrize("ellipsoid", ELLIPSOIDS, ids=ELLIPSOID_NAMES)
+def test_normal_gravity_computed_on_internal_point(ellipsoid):
+    """
+    Check if warn is raised if height is negative
+    """
+    latitude = np.linspace(-90, 90, 100)
+    with warnings.catch_warnings(record=True) as warn:
+        ellipsoid.normal_gravity(latitude, height=-10)
+        assert len(warn) >= 1
Repository: fatiando/harmonica

Issue:
Raise error if masses array has not the same number of elements as points
**Description of the desired feature**

On the point mass forward model would be nice to check if the `masses` has the same number of elements as the points coordinates inside `points`. On the tesseroid forward model this is done, but for some reason we forgot to add it on the point mass case.


<!-- Please be as detailed as you can in your description. If possible, include an example of how you would like to use this feature (even better if it's a code example). -->


**Are you willing to help implement and maintain this feature?** Yes

<!-- Every feature we add is code that we will have to maintain and keep updated. This takes a lot of effort. If you are willing to be involved in the project and help maintain your feature, it will make it easier for us to accept it. -->


Comments:

Patch:
diff --git a/harmonica/forward/point_mass.py b/harmonica/forward/point_mass.py
index 353b57d..eff34cd 100644
--- a/harmonica/forward/point_mass.py
+++ b/harmonica/forward/point_mass.py
@@ -178,9 +178,15 @@ def point_mass_gravity(
     cast = np.broadcast(*coordinates[:3])
     result = np.zeros(cast.size, dtype=dtype)
     # Prepare arrays to be passed to the jitted functions
-    coordinates = (np.atleast_1d(i).ravel().astype(dtype) for i in coordinates[:3])
-    points = (np.atleast_1d(i).ravel().astype(dtype) for i in points[:3])
+    coordinates = tuple(np.atleast_1d(i).ravel().astype(dtype) for i in coordinates[:3])
+    points = tuple(np.atleast_1d(i).ravel().astype(dtype) for i in points[:3])
     masses = np.atleast_1d(masses).astype(dtype).ravel()
+    # Sanity checks
+    if masses.size != points[0].size:
+        raise ValueError(
+            "Number of elements in masses ({}) ".format(masses.size)
+            + "mismatch the number of points ({})".format(points[0].size)
+        )
     # Compute gravitational field
     dispatchers[coordinate_system](
         *coordinates, *points, masses, result, kernels[coordinate_system][field]


Test patch:
diff --git a/harmonica/tests/test_point_mass.py b/harmonica/tests/test_point_mass.py
index 79f3c4c..3735e5c 100644
--- a/harmonica/tests/test_point_mass.py
+++ b/harmonica/tests/test_point_mass.py
@@ -40,6 +40,23 @@ def test_invalid_field():
             )
 
 
+def test_invalid_masses_array():
+    "Check if error is raised when masses shape does not match points shape"
+    # Create a set of 3 point masses
+    points = [[-10, 0, 10], [-10, 0, 10], [-100, 0, 100]]
+    # Generate a two element masses
+    masses = [1000, 2000]
+    coordinates = [0, 0, 250]
+    with pytest.raises(ValueError):
+        point_mass_gravity(
+            coordinates,
+            points,
+            masses,
+            field="potential",
+            coordinate_system="cartesian",
+        )
+
+
 # ---------------------------
 # Cartesian coordinates tests
 # ---------------------------
Repository: fatiando/pooch

Issue:
Automatically add a trailing "/" to base_url in pooch.create
**Description of the problem:**

In order to define a `Pooch` with a DOI, the DOI needs to end on a `/`. However, that character is not part of the DOI (e.g. https://dx.doi.org/ does not understand the DOI with `/`) and should not be needed here. The root of the problem is very likely a too similar handling of URLs and DOIs.


**Full code that generated the error**

Using the example from [the official docs](https://www.fatiando.org/pooch/latest/protocols.html#digital-object-identifiers-dois) and stripping the trailing `/` from `base_url`:
```python
POOCH = pooch.create(
    path=pooch.os_cache("plumbus"),
    # Use the figshare DOI
    base_url="doi:10.6084/m9.figshare.14763051.v1",
    registry={
        "tiny-data.txt": "md5:70e2afd3fd7e336ae478b1e740a5f08e",
        "store.zip": "md5:7008231125631739b64720d1526619ae",
    },
)

def fetch_tiny_data():
    """
    Load the tiny data as a numpy array.
    """
    fname = POOCH.fetch("tiny-data.txt")
    data = numpy.loadtxt(fname)
    return data
```


**Full error message**

```
ValueError: Archive with doi:10.6084/m9.figshare.14763051.v1tiny-data.txt not found (see https://doi.org/10.6084/m9.figshare.14763051.v1tiny-data.txt). Is the DOI correct?
```

Comments:

Patch:
diff --git a/pooch/core.py b/pooch/core.py
index aa8ab13..06d3362 100644
--- a/pooch/core.py
+++ b/pooch/core.py
@@ -295,8 +295,8 @@ def create(
         Base URL for the remote data source. All requests will be made relative
         to this URL. The string should have a ``{version}`` formatting mark in
         it. We will call ``.format(version=version)`` on this string. If the
-        URL is a directory path, it must end in a ``'/'`` because we will not
-        include it.
+        URL does not end in a ``'/'``, a trailing ``'/'`` will be added
+        automatically.
     version : str or None
         The version string for your project. Should be PEP440 compatible. If
         None is given, will not attempt to format *base_url* and no subfolder
@@ -423,6 +423,8 @@ def create(
     path = cache_location(path, env, version)
     if isinstance(allow_updates, str):
         allow_updates = os.environ.get(allow_updates, "true").lower() != "false"
+    # add trailing "/"
+    base_url = base_url.rstrip("/") + "/"
     pup = Pooch(
         path=path,
         base_url=base_url,


Test patch:
diff --git a/pooch/tests/test_core.py b/pooch/tests/test_core.py
index c1b1702..0a46aea 100644
--- a/pooch/tests/test_core.py
+++ b/pooch/tests/test_core.py
@@ -382,6 +382,15 @@ def test_pooch_update_disallowed_environment():
         os.environ.pop(variable_name)
 
 
+def test_pooch_create_base_url_no_trailing_slash():
+    """
+    Test if pooch.create appends a trailing slash to the base url if missing
+    """
+    base_url = "https://mybase.url"
+    pup = create(base_url=base_url, registry=None, path=DATA_DIR)
+    assert pup.base_url == base_url + "/"
+
+
 @pytest.mark.network
 def test_pooch_corrupted(data_dir_mirror):
     "Raise an exception if the file hash doesn't match the registry"