nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: skypyproject/skypy
Pull request #263 (2020-09-04 08:29:34)

flag to show skypy version
Adds a flag to the `skypy` command that outputs the version of the library.

```bash
$ skypy --version
0.1.dev141+g84a818c
```

ntessore: I thought it unnecessary to test argparse, but perhaps this guards against someone removing the version flag. Feel free to commit here 

Patch:
diff --git a/skypy/pipeline/scripts/skypy.py b/skypy/pipeline/scripts/skypy.py
index a32a256..943e7bd 100644
--- a/skypy/pipeline/scripts/skypy.py
+++ b/skypy/pipeline/scripts/skypy.py
@@ -35,6 +35,7 @@ values as keyword arguments.
 """
 
 import argparse
+from skypy import __version__ as skypy_version
 from skypy.pipeline.driver import SkyPyDriver
 import sys
 
@@ -66,6 +67,7 @@ def main(args=None):
     import yaml
 
     parser = argparse.ArgumentParser(description="SkyPy pipeline driver")
+    parser.add_argument('--version', action='version', version=skypy_version)
     parser.add_argument('config', type=argparse.FileType('r'),
                         help='Config file name')
     parser.add_argument('-f', '--format', required=False,


Test patch:
diff --git a/skypy/pipeline/tests/test_skypy.py b/skypy/pipeline/tests/test_skypy.py
index eb44563..31d2969 100644
--- a/skypy/pipeline/tests/test_skypy.py
+++ b/skypy/pipeline/tests/test_skypy.py
@@ -1,5 +1,8 @@
 from astropy.utils.data import get_pkg_data_filename
+from contextlib import redirect_stdout
+from io import StringIO
 import pytest
+from skypy import __version__ as skypy_version
 from skypy.pipeline.scripts import skypy
 
 
@@ -15,6 +18,14 @@ def test_skypy():
         skypy.main(['--help'])
     assert e.value.code == 0
 
+    # Argparse version
+    version = StringIO()
+    with pytest.raises(SystemExit) as e:
+        with redirect_stdout(version):
+            skypy.main(['--version'])
+    assert version.getvalue().strip() == skypy_version
+    assert e.value.code == 0
+
     # Missing positional argument 'config'
     with pytest.raises(SystemExit) as e:
         skypy.main(['--format', 'fits'])
Repository: skypyproject/skypy
Pull request #555 (2022-07-01 11:44:51)

TST: Adding unit test for TabulatedPowerSpectrum
## Description
This PR adds a unit test for the TabulatedPowerSpectrum class in the [skypy.power_spectrum._base](https://github.com/skypyproject/skypy/blob/module/power_spectrum/skypy/power_spectrum/_base.py) module.

## Checklist
- [x] Follow the [Contributor Guidelines](https://github.com/skypyproject/skypy/blob/main/CONTRIBUTING.rst)
- [x] Write unit tests



Patch:
diff --git a/skypy/power_spectrum/__init__.py b/skypy/power_spectrum/__init__.py
index 2269345..8564def 100644
--- a/skypy/power_spectrum/__init__.py
+++ b/skypy/power_spectrum/__init__.py
@@ -48,3 +48,4 @@ from ._camb import *  # noqa F401,F403
 from ._eisenstein_hu import *  # noqa F401,F403
 from ._halofit import *  # noqa F401,F403
 from ._growth import *  # noqa F401,F403
+from ._base import * # noqa F401,F403


Test patch:
diff --git a/skypy/power_spectrum/tests/test_base.py b/skypy/power_spectrum/tests/test_base.py
new file mode 100644
index 0000000..500f3de
--- /dev/null
+++ b/skypy/power_spectrum/tests/test_base.py
@@ -0,0 +1,21 @@
+import numpy as np
+
+
+def test_TabulatedPowerSpectrum():
+    from skypy.power_spectrum import TabulatedPowerSpectrum
+
+    def power_spectrum_dummy(wavenumber, redshift):
+        # returns log10 power spectrum on redshift wavelength grid -> 2D
+        return 0.4*redshift[:, np.newaxis] + 0.2*np.log10(wavenumber) + 2
+
+    wavenumber = np.linspace(800, 9000, 100)
+    redshift = np.linspace(0, 3, 50)
+    power_spectrum = np.power(10, power_spectrum_dummy(wavenumber, redshift))
+    tab_power_spectrum = TabulatedPowerSpectrum(wavenumber, redshift, power_spectrum)
+
+    wavenumber_test = np.linspace(1100, 7000, 100)
+    redshift_test = np.linspace(1, 2, 50)
+    interp_power = tab_power_spectrum(wavenumber_test, redshift_test)
+    power_spectrum_test = np.power(10, power_spectrum_dummy(wavenumber_test, redshift_test))
+
+    assert np.allclose(interp_power, power_spectrum_test)