nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: bluenviron/gortsplib
Pull request #668 (2024-12-25 12:49:38)

server: add ServerConn.Session() method

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/bluenviron/gortsplib/pull/668?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bluenviron) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 82.02%. Comparing base [(`4d3d6bc`)](https://app.codecov.io/gh/bluenviron/gortsplib/commit/4d3d6bc108f37291e299ab6f7a42e8067377468c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bluenviron) to head [(`e213c0f`)](https://app.codecov.io/gh/bluenviron/gortsplib/commit/e213c0f1c3f92fa2b337a1f37a59ead592d231ef?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bluenviron).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #668      +/-   ##
==========================================
+ Coverage   81.95%   82.02%   +0.06%     
==========================================
  Files         120      120              
  Lines       12419    12421       +2     
==========================================
+ Hits        10178    10188      +10     
+ Misses       1824     1819       -5     
+ Partials      417      414       -3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/bluenviron/gortsplib/pull/668?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bluenviron).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bluenviron).


Patch:
diff --git a/server_conn.go b/server_conn.go
index b8b80444..47d06f23 100644
--- a/server_conn.go
+++ b/server_conn.go
@@ -124,6 +124,11 @@ func (sc *ServerConn) UserData() interface{} {
 	return sc.userData
 }
 
+// Session returns associated session.
+func (sc *ServerConn) Session() *ServerSession {
+	return sc.session
+}
+
 // Stats returns connection statistics.
 func (sc *ServerConn) Stats() *StatsConn {
 	return &StatsConn{


Test patch:
diff --git a/server_play_test.go b/server_play_test.go
index 0c1edbaa..7c40b200 100644
--- a/server_play_test.go
+++ b/server_play_test.go
@@ -642,6 +642,8 @@ func TestServerPlay(t *testing.T) {
 						}, stream, nil
 					},
 					onPlay: func(ctx *ServerHandlerOnPlayCtx) (*base.Response, error) {
+						require.NotNil(t, ctx.Conn.Session())
+
 						switch transport {
 						case "udp":
 							v := TransportUDP
Repository: cornellius-gp/gpytorch
Pull request #944 (2019-11-14 15:06:56)

Cholesky gives a better error when there are NaNs
Based on a note in #943 

jacobrgardner: @gpleiss Does this actually address #943? Like, definitely agree we want Cholesky to raise a more specific error, but if the real problem is that our SVGP regression notebook is crashing, we probably want to do more than have a nicer error message 😅 
gpleiss: Maybe "addresses" is the wrong word. But I think the nicer error message does make our lives better.
jacobrgardner: Yeah, no arguments here about merging the PR! I just want to make sure we don't close the issue until the example runs through.

Patch:
diff --git a/.isort.cfg b/.isort.cfg
index 92b18f67..3e8d8aaf 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,2 +1,2 @@
 [settings]
-known_third_party = matplotlib,numpy,pyro,setuptools,sphinx_rtd_theme,torch
+known_third_party = gpytorch,matplotlib,numpy,pyro,setuptools,sphinx_rtd_theme,torch
diff --git a/gpytorch/utils/cholesky.py b/gpytorch/utils/cholesky.py
index 0f93dde6..77d2c33a 100644
--- a/gpytorch/utils/cholesky.py
+++ b/gpytorch/utils/cholesky.py
@@ -4,6 +4,8 @@ import warnings
 
 import torch
 
+from .errors import NanError
+
 
 def psd_safe_cholesky(A, upper=False, out=None, jitter=None):
     """Compute the Cholesky decomposition of A. If A is only p.s.d, add a small jitter to the diagonal.
@@ -22,6 +24,12 @@ def psd_safe_cholesky(A, upper=False, out=None, jitter=None):
         L = torch.cholesky(A, upper=upper, out=out)
         return L
     except RuntimeError as e:
+        isnan = torch.isnan(A)
+        if isnan.any():
+            raise NanError(
+                f"cholesky_cpu: {isnan.sum().item()} of {A.numel()} elements of the {A.shape} tensor are NaN."
+            )
+
         if jitter is None:
             jitter = 1e-6 if A.dtype == torch.float32 else 1e-8
         Aprime = A.clone()
diff --git a/gpytorch/utils/errors.py b/gpytorch/utils/errors.py
new file mode 100644
index 00000000..e0dffe3b
--- /dev/null
+++ b/gpytorch/utils/errors.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+
+class NanError(RuntimeError):
+    pass
+
+
+__all__ = ["NanError"]


Test patch:
diff --git a/test/utils/test_cholesky.py b/test/utils/test_cholesky.py
index a72e76ef..7ae7d164 100644
--- a/test/utils/test_cholesky.py
+++ b/test/utils/test_cholesky.py
@@ -7,12 +7,19 @@ import torch
 
 from gpytorch.test.utils import least_used_cuda_device
 from gpytorch.utils.cholesky import psd_safe_cholesky
+from gpytorch.utils.errors import NanError
 
 
 class TestPSDSafeCholesky(unittest.TestCase):
     def _gen_test_psd(self):
         return torch.tensor([[[0.25, -0.75], [-0.75, 2.25]], [[1.0, 1.0], [1.0, 1.0]]])
 
+    def test_psd_safe_cholesky_nan(self, cuda=False):
+        A = self._gen_test_psd().sqrt()
+        with self.assertRaises(NanError) as ctx:
+            psd_safe_cholesky(A)
+            self.assertTrue("NaN" in ctx.exception)
+
     def test_psd_safe_cholesky_pd(self, cuda=False):
         device = torch.device("cuda") if cuda else torch.device("cpu")
         for dtype in (torch.float, torch.double):
Repository: cornellius-gp/gpytorch
Pull request #1072 (2020-03-07 20:01:06)

Let scale kernel inherit active_dims of base_kernel
When applying a scale kernel to a kernel with both active dims and
ard, the scale kernel does not properly implement the forward method
unless active_dims is not supplied also in the scale kernel
definition. (See the test case for example.)

The behaviour is changed so that the base_kernel active_dims are
checked before initializing the scale kernel and including the active
dims into the kwargs if present in the base_kernel.


Patch:
diff --git a/gpytorch/kernels/scale_kernel.py b/gpytorch/kernels/scale_kernel.py
index 9f8e9eae..812f26a4 100644
--- a/gpytorch/kernels/scale_kernel.py
+++ b/gpytorch/kernels/scale_kernel.py
@@ -59,6 +59,8 @@ class ScaleKernel(Kernel):
         return self.base_kernel.is_stationary
 
     def __init__(self, base_kernel, outputscale_prior=None, outputscale_constraint=None, **kwargs):
+        if base_kernel.active_dims is not None:
+            kwargs["active_dims"] = base_kernel.active_dims
         super(ScaleKernel, self).__init__(**kwargs)
         if outputscale_constraint is None:
             outputscale_constraint = Positive()


Test patch:
diff --git a/test/kernels/test_scale_kernel.py b/test/kernels/test_scale_kernel.py
index 23efc40e..220d7cf4 100644
--- a/test/kernels/test_scale_kernel.py
+++ b/test/kernels/test_scale_kernel.py
@@ -112,6 +112,15 @@ class TestScaleKernel(BaseKernelTestCase, unittest.TestCase):
         kernel = ScaleKernel(LinearKernel())
         self.assertFalse(kernel.is_stationary)
 
+    def test_inherit_active_dims(self):
+        lengthscales = torch.tensor([1, 1], dtype=torch.float)
+        base_kernel = RBFKernel(active_dims=(1, 2), ard_num_dims=2)
+        base_kernel.initialize(lengthscale=lengthscales)
+        kernel = ScaleKernel(base_kernel)
+        kernel.initialize(outputscale=torch.tensor([3], dtype=torch.float))
+        kernel.eval()
+        self.assertTrue(torch.all(kernel.active_dims == base_kernel.active_dims))
+
 
 if __name__ == "__main__":
     unittest.main()