nebius/SWE-bench-extra huggingface dataset:
Repository: ReactiveX/RxPY

Issue:
Scheduler provided in subscribe is not used for all observable factories
We now have `Observable.subcribe(..., scheduler=scheduler)`, which is really nice. Let's take the API all the way.

[The documentation says that](https://rxpy.readthedocs.io/en/latest/get_started.html#default-scheduler):

> Operators that accept a scheduler select the scheduler to use in the following way:
>  * If a scheduler is provided for the operator, then use it.
>  * If a default scheduler is provided in subscribe, then use it.
>  * Otherwise use the default scheduler of the operator.

I know that this applies to operators but I think that it would make sense if it also applied to observable factories. This way, we can finally get rid of all the `scheduler=scheduler` boilerplate. See #183 for additional info.

The `timer` observable factory, for instance, still defaults to the `TimeoutScheduler` .

I guess this is a feature request.

Comments:

Patch:
diff --git a/rx/core/observable/connectableobservable.py b/rx/core/observable/connectableobservable.py
index f2d3637e..ab0acd51 100644
--- a/rx/core/observable/connectableobservable.py
+++ b/rx/core/observable/connectableobservable.py
@@ -28,7 +28,7 @@ class ConnectableObservable(Observable):
             def dispose():
                 self.has_subscription = False
 
-            subscription = self.source.subscribe(self.subject, scheduler)
+            subscription = self.source.subscribe(self.subject, scheduler=scheduler)
             self.subscription = CompositeDisposable(subscription, Disposable(dispose))
 
         return self.subscription


Test patch:
diff --git a/tests/test_observable/test_connectableobservable.py b/tests/test_observable/test_connectableobservable.py
index 00709145..8ab7a4e2 100644
--- a/tests/test_observable/test_connectableobservable.py
+++ b/tests/test_observable/test_connectableobservable.py
@@ -241,3 +241,19 @@ class TestConnectableObservable(unittest.TestCase):
             subscribe(225, 241),
             subscribe(249, 255),
             subscribe(275, 295)]
+
+    def test_connectable_observable_forward_scheduler(self):
+        scheduler = TestScheduler()
+        subscribe_scheduler = 'unknown'
+
+        def subscribe(observer, scheduler=None):
+            nonlocal subscribe_scheduler
+            subscribe_scheduler = scheduler
+
+        xs = rx.create(subscribe)
+        subject = MySubject()
+
+        conn = ConnectableObservable(xs, subject)
+        conn.connect(scheduler)
+
+        assert subscribe_scheduler is scheduler
Repository: RemDelaporteMathurin/h-transport-materials

Issue:
Users should be told when filtered group is None

Comments:

Patch:
diff --git a/h_transport_materials/properties_group.py b/h_transport_materials/properties_group.py
index 2de20fb..9ecec3d 100644
--- a/h_transport_materials/properties_group.py
+++ b/h_transport_materials/properties_group.py
@@ -2,6 +2,7 @@ import numpy as np
 import json
 from pybtex.database import BibliographyData
 import pint
+import warnings
 
 from h_transport_materials.fitting import fit_arhenius
 from h_transport_materials import ureg, ArrheniusProperty
@@ -66,7 +67,8 @@ class PropertiesGroup(list):
             # append the property to the filtered list
             if (match and not exclude) or (not match and exclude):
                 filtered_props.append(prop)
-
+        if len(filtered_props) == 0:
+            warnings.warn("No property matching the requirements")
         return filtered_props
 
     def mean(self, samples_per_line=5, default_range=(300, 1200)):


Test patch:
diff --git a/tests/test_properties_group.py b/tests/test_properties_group.py
index 1d22ba2..f3092bc 100644
--- a/tests/test_properties_group.py
+++ b/tests/test_properties_group.py
@@ -160,3 +160,8 @@ def test_export_to_json():
                         assert f"{getattr(prop_ref, key):~}" == val
                     else:
                         assert getattr(prop_ref, key) == val
+
+
+def test_filter_warns_when_no_props():
+    with pytest.warns(UserWarning):
+        htm.diffusivities.filter(material="material_that_doesn_not_exist")
Repository: RemDelaporteMathurin/h-transport-materials

Issue:
PropertiesGroup.mean should have units
```python
import h_transport_materials as htm

print(htm.diffusivities.mean().units)
```

Prints

```
dimensionless
```

Comments:

Patch:
diff --git a/h_transport_materials/properties_group.py b/h_transport_materials/properties_group.py
index ccc4b5f..1099a1b 100644
--- a/h_transport_materials/properties_group.py
+++ b/h_transport_materials/properties_group.py
@@ -92,9 +92,15 @@ class PropertiesGroup(list):
             default_range (tuple, optional): temperature range taken if
                 a Property doesn't have range. Defaults to (300, 1200).
 
+        Raises:
+            ValueError: When called on a mixed units group
+
         Returns:
             ArrheniusProperty: the mean arrhenius property
         """
+        if self.units == "mixed units":
+            raise ValueError("Can't compute mean on mixed units groups")
+
         # initialise data points
         data_T = np.array([])
         data_y = np.array([])
diff --git a/h_transport_materials/property.py b/h_transport_materials/property.py
index c2d7cee..b9994e2 100644
--- a/h_transport_materials/property.py
+++ b/h_transport_materials/property.py
@@ -184,6 +184,15 @@ class ArrheniusProperty(Property):
 
     @property
     def units(self):
+        # check if data_y is set
+        if hasattr(self, "data_y"):
+            if self.data_y is not None:
+                return self.data_y.units
+        # check if pre_exp is set
+        if hasattr(self, "pre_exp"):
+            return self.pre_exp.units
+
+        # return dimensionless by default
         return ureg.dimensionless
 
     @property


Test patch:
diff --git a/tests/test_properties_group.py b/tests/test_properties_group.py
index 31ab5cd..cd40a60 100644
--- a/tests/test_properties_group.py
+++ b/tests/test_properties_group.py
@@ -88,7 +88,7 @@ def test_mean(mean_D_0, mean_E_D):
     mean_prop = my_group.mean()
 
     # test
-    assert mean_prop.pre_exp == pytest.approx(mean_D_0, rel=0.2)
+    assert mean_prop.pre_exp.magnitude == pytest.approx(mean_D_0, rel=0.2)
     assert mean_prop.act_energy.magnitude == pytest.approx(mean_E_D, rel=0.2)
 
 
@@ -196,3 +196,20 @@ def test_units_property():
 
 def test_to_latex_table():
     htm.diffusivities.to_latex_table()
+
+
+def test_mean_has_units():
+    assert htm.diffusivities.mean().units == htm.ureg.m**2 * htm.ureg.s**-1
+
+
+def test_cannot_compute_mean_on_mixed_groups():
+    prop1 = htm.ArrheniusProperty(
+        0.1 * htm.ureg.dimensionless, 0.1 * htm.ureg.eV * htm.ureg.particle**-1
+    )
+    prop2 = htm.ArrheniusProperty(
+        0.1 * htm.ureg.m, 0.1 * htm.ureg.eV * htm.ureg.particle**-1
+    )
+    my_group = htm.PropertiesGroup([prop1, prop2])
+
+    with pytest.raises(ValueError, match="Can't compute mean on mixed units groups"):
+        my_group.mean()
Repository: RemDelaporteMathurin/h-transport-materials

Issue:
Inf pre-exponential factor on mean permeabilities
On HTM 0.13.1:

```python
import h_transport_materials as htm

perm = htm.permeabilities.filter(material="steel").mean()

print(perm)
```


```
C:\Users\remidm\AppData\Roaming\Python\Python311\site-packages\numpy\core\_methods.py:53: RuntimeWarning: overflow encountered in reduce
  return umr_prod(a, axis, dtype, out, keepdims, initial, where)

        Author:
        Material:
        Year: None
        Isotope: None
        Pre-exponential factor: inf particle/Pa⁰⋅⁵/m/s
        Activation energy: 5.73×10⁻¹ eV/particle
```

Comments:

Patch:
diff --git a/h_transport_materials/properties_group.py b/h_transport_materials/properties_group.py
index 60ba476..590fe85 100644
--- a/h_transport_materials/properties_group.py
+++ b/h_transport_materials/properties_group.py
@@ -94,7 +94,11 @@ class PropertiesGroup(list):
 
         # geometric mean of pre-exponential factor
         pre_exps = np.array([prop.pre_exp.magnitude for prop in self])
-        pre_exp = pre_exps.prod() ** (1.0 / len(pre_exps))
+        scaling_factor = np.max(pre_exps)
+        pre_exps = pre_exps / scaling_factor  # scale pre-exps to avoid inf
+
+        pre_exp = pre_exps.prod() ** (1.0 / len(pre_exps))  # compute mean
+        pre_exp = pre_exp * scaling_factor  # re-scale
 
         # arithmetic mean of activation energy
         act_energy = np.array([prop.act_energy.magnitude for prop in self]).mean()


Test patch:
diff --git a/tests/test_properties_group.py b/tests/test_properties_group.py
index 711d54f..84f1b21 100644
--- a/tests/test_properties_group.py
+++ b/tests/test_properties_group.py
@@ -215,3 +215,10 @@ def test_cannot_compute_mean_on_mixed_groups():
 
     with pytest.raises(ValueError, match="Can't compute mean on mixed units groups"):
         my_group.mean()
+
+
+def test_mean_of_large_numbers_properties():
+    """This test catches bug reported in issue #242"""
+
+    perm = htm.permeabilities.filter(material="steel").mean()
+    assert not np.isinf(perm.pre_exp)
Repository: RemDelaporteMathurin/h-transport-materials

Issue:
Temperature range should be determined by data_T

Comments:

Patch:
diff --git a/h_transport_materials/property.py b/h_transport_materials/property.py
index 8174d74..4cc3aee 100644
--- a/h_transport_materials/property.py
+++ b/h_transport_materials/property.py
@@ -67,6 +67,16 @@ class ArrheniusProperty(Property):
         self.data_y = data_y
         super().__init__(**kwargs)
 
+    @property
+    def range(self):
+        if self._range is None and self.data_T is not None:
+            self.fit()
+        return self._range
+
+    @range.setter
+    def range(self, value):
+        self._range = value
+
     @property
     def pre_exp(self):
         if self._pre_exp is None and self.data_T is not None:
@@ -121,6 +131,7 @@ class ArrheniusProperty(Property):
 
     def fit(self):
         self.pre_exp, self.act_energy = fit_arhenius(self.data_y, self.data_T)
+        self.range = (self.data_T.min(), self.data_T.max())
 
     def value(self, T, exp=np.exp):
         return self.pre_exp * exp(-self.act_energy / k_B / T)


Test patch:
diff --git a/tests/test_arhenius_property.py b/tests/test_arhenius_property.py
index 995e830..b030537 100644
--- a/tests/test_arhenius_property.py
+++ b/tests/test_arhenius_property.py
@@ -64,3 +64,14 @@ def test_value(T, pre_exp, act_energy):
     computed_value = my_prop.value(T=T)
     expected_value = pre_exp * np.exp(-act_energy / htm.k_B / T)
     assert expected_value == computed_value
+
+
+def test_fit_creates_temp_range():
+    """Checks that when given data_T and data_y,
+    ArrheniusProperty.range is based on data_T"""
+    my_prop = htm.ArrheniusProperty(
+        data_T=[300, 400, 500],
+        data_y=[1, 2, 3],
+    )
+
+    assert my_prop.range == (300, 500)