nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: conan-io/conan
Pull request #13739 (2023-04-20 21:44:51)

fix CMakeToolchain CMAKE_SYSTEM_NAME=Generic for baremetal
Changelog: Bugfix: fix CMakeToolchain CMAKE_SYSTEM_NAME=Generic for baremetal
Docs: Omit

Close https://github.com/conan-io/conan/issues/13735


Patch:
diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py
index e24398245..6c021bc74 100644
--- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -718,6 +718,7 @@ class GenericSystemBlock(Block):
         arch_build = self._conanfile.settings_build.get_safe("arch")
         cmake_system_name_map = {"Neutrino": "QNX",
                                  "": "Generic",
+                                 "baremetal": "Generic",
                                  None: "Generic"}
         if os_host != os_build:
             return cmake_system_name_map.get(os_host, os_host)


Test patch:
diff --git a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
index cfa06ebf9..a5e2bec1a 100644
--- a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
+++ b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
@@ -527,3 +527,33 @@ def test_linker_scripts_block(conanfile):
     toolchain = CMakeToolchain(conanfile)
     content = toolchain.content
     assert f'string(APPEND CONAN_EXE_LINKER_FLAGS -T"path_to_first_linker_script" -T"path_to_second_linker_script")' in content
+
+
+class TestCrossBuild:
+    @pytest.fixture
+    def conanfile_cross(self):
+        c = ConanFile()
+        c.settings = Settings({"os": ["baremetal", "Linux"],
+                               "compiler": {"gcc": {"version": ["11"], "cppstd": ["20"]}},
+                               "build_type": ["Release"],
+                               "arch": ["armv8", "x86_64"]})
+        c.settings.build_type = "Release"
+        c.settings.arch = "armv8"
+        c.settings.compiler = "gcc"
+        c.settings.compiler.version = "11"
+        c.settings.compiler.cppstd = "20"
+        c.settings.os = "baremetal"
+        c.settings_build = c.settings.copy()
+        c.settings_build.os = "Linux"
+        c.settings_build.arch = "x86_64"
+        c.conf = Conf()
+        c.folders.set_base_generators(".")
+        c._conan_node = Mock()
+        c._conan_node.dependencies = []
+        c._conan_node.transitive_deps = {}
+        return c
+
+    def test_cmake_system_name(self, conanfile_cross):
+        toolchain = CMakeToolchain(conanfile_cross)
+        content = toolchain.content
+        assert 'set(CMAKE_SYSTEM_NAME Generic)' in content
Repository: conan-io/conan
Pull request #13815 (2023-05-04 15:07:35)

fix AutotoolsToolchain when unknown compiler
Changelog: Bugfix: fix AutotoolsToolchain when unknown compiler
Docs: Omit

Close https://github.com/conan-io/conan/issues/13813



Patch:
diff --git a/conan/tools/_compilers.py b/conan/tools/_compilers.py
index fb976a469..8172bd6df 100644
--- a/conan/tools/_compilers.py
+++ b/conan/tools/_compilers.py
@@ -165,7 +165,7 @@ def build_type_flags(settings):
                      "MinSizeRel": ["-xO2", "-xspace"],
                      }.get(build_type, [])
             return flags
-    return ""
+    return []
 
 
 def use_win_mingw(conanfile):


Test patch:
diff --git a/conans/test/integration/toolchains/gnu/test_autotoolstoolchain.py b/conans/test/integration/toolchains/gnu/test_autotoolstoolchain.py
index 4bc28f2fe..e8959920d 100644
--- a/conans/test/integration/toolchains/gnu/test_autotoolstoolchain.py
+++ b/conans/test/integration/toolchains/gnu/test_autotoolstoolchain.py
@@ -4,6 +4,7 @@ import textwrap
 
 from conans.test.assets.genconanfile import GenConanfile
 from conans.test.utils.tools import TestClient
+from conans.util.files import save, load
 
 
 def test_extra_flags_via_conf():
@@ -75,6 +76,7 @@ def test_linker_scripts_via_conf():
     else:
         assert 'export LDFLAGS="$LDFLAGS --flag5 --flag6 -T\'/linker/scripts/flash.ld\' -T\'/linker/scripts/extra_data.ld\'"' in toolchain
 
+
 def test_not_none_values():
 
     conanfile = textwrap.dedent("""
@@ -123,3 +125,15 @@ def test_set_prefix():
     conanbuild = client.load(os.path.join(client.current_folder, "build", "conan", "conanbuild.conf"))
     assert "--prefix=/somefolder" in conanbuild
     assert conanbuild.count("--prefix") == 1
+
+
+def test_unknown_compiler():
+    client = TestClient()
+    settings = load(client.cache.settings_path)
+    settings = settings.replace("gcc:", "xlc:\n    gcc:", 1)
+    save(client.cache.settings_path, settings)
+    client.save({"conanfile.py": GenConanfile().with_settings("compiler", "build_type")
+                                               .with_generator("AutotoolsToolchain")})
+    # this used to crash, because of build_type_flags in AutotoolsToolchain returning empty string
+    client.run("install . -s compiler=xlc")
+    assert "conanfile.py: Generator 'AutotoolsToolchain' calling 'generate()'" in client.out
Repository: conan-io/conan
Pull request #13867 (2023-05-10 20:58:34)

fix AutotoolsToolchain compiler_executable unix_paths
Changelog: Fix: fix ``AutotoolsToolchain`` definition of  ``tools.build:compiler_executable`` for Windows subsystems
Docs: Omit

Close https://github.com/conan-io/conan/issues/13780



Patch:
diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py
index b44308132..6150e1ba2 100644
--- a/conan/tools/gnu/autotoolstoolchain.py
+++ b/conan/tools/gnu/autotoolstoolchain.py
@@ -6,7 +6,7 @@ from conan.tools.build.cross_building import cross_building
 from conan.tools.build.flags import architecture_flag, build_type_flags, cppstd_flag, build_type_link_flags, libcxx_flags
 from conan.tools.env import Environment
 from conan.tools.gnu.get_gnu_triplet import _get_gnu_triplet
-from conan.tools.microsoft import VCVars, msvc_runtime_flag
+from conan.tools.microsoft import VCVars, msvc_runtime_flag, unix_path
 from conans.errors import ConanException
 from conans.model.pkg_type import PackageType
 
@@ -152,7 +152,10 @@ class AutotoolsToolchain:
             compilers_mapping = {"c": "CC", "cpp": "CXX", "cuda": "NVCC", "fortran": "FC"}
             for comp, env_var in compilers_mapping.items():
                 if comp in compilers_by_conf:
-                    env.define(env_var, compilers_by_conf[comp])
+                    compiler = compilers_by_conf[comp]
+                    # https://github.com/conan-io/conan/issues/13780
+                    compiler = unix_path(self._conanfile, compiler)
+                    env.define(env_var, compiler)
         env.append("CPPFLAGS", ["-D{}".format(d) for d in self.defines])
         env.append("CXXFLAGS", self.cxxflags)
         env.append("CFLAGS", self.cflags)


Test patch:
diff --git a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
index 09a2f0f3f..59af29058 100644
--- a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
+++ b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py
@@ -525,3 +525,17 @@ def test_extra_flags_via_conf():
     assert '-mios-version-min=14 --flag1 --flag2' in env["CXXFLAGS"]
     assert '-mios-version-min=14 --flag3 --flag4' in env["CFLAGS"]
     assert '-mios-version-min=14 --flag5 --flag6' in env["LDFLAGS"]
+
+
+def test_conf_compiler_executable():
+    conanfile = ConanFileMock()
+    conanfile.conf.define("tools.build:compiler_executables", {"cpp": "C:/my/path/myg++"})
+    conanfile.conf.define("tools.microsoft.bash:subsystem", "msys2")
+    conanfile.win_bash = True
+    conanfile.settings = MockSettings(
+        {"build_type": "Release",
+         "os": "Windows"})
+    conanfile.settings_build = conanfile.settings
+    be = AutotoolsToolchain(conanfile)
+    env = be.vars()
+    assert "/c/my/path/myg++" == env["CXX"]
Repository: conan-io/conan
Pull request #14668 (2023-09-05 13:19:21)

Add nobara distro -> dnf package manager mapping.
Changelog: Feature: Add nobara distro -> dnf package manager mapping.
Docs: Omit

- [x] #14665
- [x] I've read the [Contributing guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [x] I've followed the PEP8 style guides for Python code.



Patch:
diff --git a/conan/tools/system/package_manager.py b/conan/tools/system/package_manager.py
index b5476f376..a274e96d9 100644
--- a/conan/tools/system/package_manager.py
+++ b/conan/tools/system/package_manager.py
@@ -43,7 +43,7 @@ class _SystemPackageManagerTool(object):
                            "apk": ["alpine"],
                            "yum": ["pidora", "scientific", "xenserver", "amazon", "oracle", "amzn",
                                    "almalinux", "rocky"],
-                           "dnf": ["fedora", "rhel", "centos", "mageia"],
+                           "dnf": ["fedora", "rhel", "centos", "mageia", "nobara"],
                            "brew": ["Darwin"],
                            "pacman": ["arch", "manjaro", "msys2", "endeavouros"],
                            "choco": ["Windows"],
diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py
index b04582ab7..6354b9fd7 100644
--- a/conans/client/conf/detect.py
+++ b/conans/client/conf/detect.py
@@ -331,6 +331,8 @@ def _detected_architecture():
         return "sparc"
     elif "aarch64" in machine:
         return "armv8"
+    elif "ARM64" in machine:
+        return "armv8"
     elif "arm64" in machine:
         return "armv8"
     elif "64" in machine:


Test patch:
diff --git a/conans/test/integration/tools/system/package_manager_test.py b/conans/test/integration/tools/system/package_manager_test.py
index 01fd50276..9c268e553 100644
--- a/conans/test/integration/tools/system/package_manager_test.py
+++ b/conans/test/integration/tools/system/package_manager_test.py
@@ -48,6 +48,7 @@ def test_msys2():
     ("pidora", "yum"),
     ("rocky", "yum"),
     ("fedora", "dnf"),
+    ("nobara", "dnf"),
     ("arch", "pacman"),
     ("opensuse", "zypper"),
     ("sles", "zypper"),
diff --git a/conans/test/unittests/util/detected_architecture_test.py b/conans/test/unittests/util/detected_architecture_test.py
index b187912c2..b95d5e147 100644
--- a/conans/test/unittests/util/detected_architecture_test.py
+++ b/conans/test/unittests/util/detected_architecture_test.py
@@ -31,7 +31,9 @@ class DetectedArchitectureTest(unittest.TestCase):
         ['sparc64', 'sparcv9'],
         ['s390', 's390'],
         ['s390x', 's390x'],
-        ['arm64', "armv8"]
+        ['arm64', "armv8"],
+        ['aarch64', 'armv8'],
+        ['ARM64', 'armv8']
     ])
     def test_various(self, mocked_machine, expected_arch):
Repository: StingraySoftware/stingray
Pull request #170 (2017-02-27 13:47:39)

added bin edges support
Hi,
This PR addresses a part of [issue-90](https://github.com/StingraySoftware/stingray/issues/90). It is to support bin edges, with `bin_lo` containing lower time stamps of all bins and `bin_hi` the corresponding higher ones.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/stingraysoftware/stingray/170)
<!-- Reviewable:end -->



Patch:
diff --git a/stingray/lightcurve.py b/stingray/lightcurve.py
index b7c95b13..7257ee08 100644
--- a/stingray/lightcurve.py
+++ b/stingray/lightcurve.py
@@ -48,6 +48,12 @@ class Lightcurve(object):
         time: numpy.ndarray
             The array of midpoints of time bins.
 
+        bin_lo:
+            The array of lower time stamp of time bins.
+
+        bin_hi:
+            The array of higher time stamp of time bins.
+
         counts: numpy.ndarray
             The counts per bin corresponding to the bins in `time`.
 
@@ -98,6 +104,9 @@ class Lightcurve(object):
         self.time = np.asarray(time)
         self.dt = time[1] - time[0]
 
+        self.bin_lo = self.time - 0.5 * self.dt
+        self.bin_hi = self.time + 0.5 * self.dt
+
         if input_counts:
             self.counts = np.asarray(counts)
             self.countrate = self.counts / self.dt


Test patch:
diff --git a/stingray/tests/test_lightcurve.py b/stingray/tests/test_lightcurve.py
index 1299767c..c3f888d7 100644
--- a/stingray/tests/test_lightcurve.py
+++ b/stingray/tests/test_lightcurve.py
@@ -52,6 +52,13 @@ class TestLightcurve(object):
         lc = Lightcurve(self.times, self.counts)
         assert lc.n == 4
 
+    def test_bin_edges(self):
+        bin_lo = [0.5,  1.5,  2.5,  3.5]
+        bin_hi = [1.5,  2.5,  3.5,  4.5]
+        lc = Lightcurve(self.times, self.counts)
+        assert np.allclose(lc.bin_lo, bin_lo)
+        assert np.allclose(lc.bin_hi, bin_hi)
+
     def test_lightcurve_from_toa(self):
         lc = Lightcurve.make_lightcurve(self.times, self.dt)
Repository: StingraySoftware/stingray
Pull request #188 (2017-05-04 11:53:41)

Check that there are times inside GTIs in bin_intervals_from_gtis
From MaltPyNT

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/stingraysoftware/stingray/188)
<!-- Reviewable:end -->



Patch:
diff --git a/stingray/gti.py b/stingray/gti.py
index f2e67ca9..986540c7 100644
--- a/stingray/gti.py
+++ b/stingray/gti.py
@@ -567,6 +567,9 @@ def bin_intervals_from_gtis(gtis, chunk_length, time):
     bintime = time[1] - time[0]
     nbin = np.long(chunk_length / bintime)
 
+    if time[-1] < np.min(gtis) or time[0] > np.max(gtis):
+        raise ValueError("Invalid time interval for the given GTIs")
+
     spectrum_start_bins = np.array([], dtype=np.long)
     for g in gtis:
         if g[1] - g[0] < chunk_length:


Test patch:
diff --git a/stingray/tests/test_gti.py b/stingray/tests/test_gti.py
index 33ecd93e..502fd7d8 100644
--- a/stingray/tests/test_gti.py
+++ b/stingray/tests/test_gti.py
@@ -137,6 +137,12 @@ class TestGTI(object):
         assert np.all(start_bins == np.array([0, 2]))
         assert np.all(stop_bins == np.array([2, 4]))
 
+    def test_decide_spectrum_lc_intervals_invalid(self):
+        with pytest.raises(ValueError):
+            a, b = bin_intervals_from_gtis([[0, 400]], 128, [500, 501])
+        with pytest.raises(ValueError):
+            a, b = bin_intervals_from_gtis([[1000, 1400]], 128, [500, 501])
+
     def test_gti_length(self):
         assert gti_len([[0, 5], [6, 7]]) == 6
Repository: StingraySoftware/stingray
Pull request #232 (2017-07-28 03:05:44)

fixed usage before refrence exception in LC.Join, and removed a potential bug


Patch:
diff --git a/stingray/lightcurve.py b/stingray/lightcurve.py
index 280ee369..6ea063ed 100644
--- a/stingray/lightcurve.py
+++ b/stingray/lightcurve.py
@@ -602,7 +602,7 @@ class Lightcurve(object):
             if self.err_dist.lower() != other.err_dist.lower():
                 simon("Lightcurves have different statistics!"
                       "We are setting the errors to zero.")
-                new_counts_err = np.zeros_like(new_counts)
+
 
             elif self.err_dist.lower() in valid_statistics:
                 valid_err = True
@@ -623,7 +623,7 @@ class Lightcurve(object):
 
             for i, time in enumerate(second_lc.time):
             
-                if (counts[time] != 0): #Common time
+                if (counts.get(time) != None): #Common time
 
                     counts[time] = (counts[time] + second_lc.counts[i]) / 2  #avg
                     counts_err[time] = np.sqrt(( ((counts_err[time]**2) + (second_lc.counts_err[i] **2)) / 2))
@@ -636,6 +636,8 @@ class Lightcurve(object):
             new_counts = list(counts.values())
             if(valid_err):
                 new_counts_err = list(counts_err.values())
+            else:
+                new_counts_err = np.zeros_like(new_counts)
             
             del[counts, counts_err]
 


Test patch:
diff --git a/stingray/tests/test_lightcurve.py b/stingray/tests/test_lightcurve.py
index 1517f55f..ce38a830 100644
--- a/stingray/tests/test_lightcurve.py
+++ b/stingray/tests/test_lightcurve.py
@@ -390,6 +390,30 @@ class TestLightcurve(object):
         assert len(lc.counts) == len(lc.time) == 6
         assert np.all(lc.counts == np.array([2, 2, 3, 3, 4, 4]))
 
+    def test_join_different_err_dist_disjoint_times(self):
+        _times = [5 , 6, 7, 8]
+        _counts =[2, 2, 2, 2]
+
+        lc1 = Lightcurve(self.times, self.counts, err_dist = "poisson")
+        lc2 = Lightcurve(_times, _counts, err_dist = "gauss")
+
+        lc3 = lc1.join(lc2)
+
+        assert np.all(lc3.counts_err[:len(self.times)] == lc1.counts_err)
+        assert np.all(lc3.counts_err[len(self.times):] == np.zeros_like(lc2.counts))
+
+    def test_join_different_err_dist_overlapping_times(self):
+        _times = [3, 4, 5, 6]
+        _counts = [4, 4, 4, 4]
+
+        lc1 = Lightcurve(self.times, self.counts, err_dist = "poisson")
+        lc2 = Lightcurve(_times, _counts, err_dist = "gauss")
+        
+        with warnings.catch_warnings(record=True) as w:
+            lc3 = lc1.join(lc2)
+            assert "We are setting the errors to zero." in str(w[1].message)
+            assert np.all(lc3.counts_err == np.zeros_like(lc3.time))
+
     def test_truncate_by_index(self):
         lc = Lightcurve(self.times, self.counts, gti=self.gti)
Repository: StingraySoftware/stingray
Pull request #247 (2017-08-16 13:06:44)

Add __reduce__ method to pickle/unpickle SincSquareModel
This is needed to pickle and unpickle these objects correctly


Patch:
diff --git a/README.rst b/README.rst
index f250f1ea..378c2f6f 100644
--- a/README.rst
+++ b/README.rst
@@ -62,7 +62,7 @@ Contents
 - cross spectra, r.m.s. spectra and lags (time vs energy, time vs frequency)
 - covariance spectra
 - bispectra
-- Bayesian quasi-periodic oscillation searches
+- Bayesian QPO searches
 - simulate a light curve with a given power spectrum
 - simulate a light curve from another light curve and a 1-d (time) or 2-d (time-energy) impulse response
 - simulate an event list from a given light curve _and_ with a given energy spectrum
@@ -73,13 +73,13 @@ Contents
 Future Additions
 ----------------
 - bicoherence
-- phase-resolved spectroscopy of quasi-periodic oscillations
-- Fourier-frequency-resolved spectroscopy
+- spectral-timing functionality
 - power colours
 - full HEASARC-compatible mission support
+- graphical interface (see StingraySoftware/DAVE)
+- (...) Feel free to propose! Use the `Issues`_ page!
 - pulsar searches with $H$-test
 - binary pulsar searches
-- (...) Feel free to propose! Use the `Issues`_ page!
 
 Installation
 ------------
diff --git a/stingray/pulse/modeling.py b/stingray/pulse/modeling.py
index c58e83fa..989d0bcb 100644
--- a/stingray/pulse/modeling.py
+++ b/stingray/pulse/modeling.py
@@ -105,8 +105,13 @@ def sinc_square_deriv(x, amplitude=1., mean=0., width=1.):
     return [d_amplitude, d_mean, d_width]
 
 
-SincSquareModel = models.custom_model(sinc_square_model,
-                                      fit_deriv=sinc_square_deriv)
+_SincSquareModel = models.custom_model(sinc_square_model,
+                                       fit_deriv=sinc_square_deriv)
+
+class SincSquareModel(_SincSquareModel):
+    def __reduce__(cls):
+        members = dict(cls.__dict__)
+        return (type(cls), (), members)
 
 
 def fit_sinc(x, y, amp=1.5, mean=0., width=1., tied={}, fixed={}, bounds={},


Test patch:
diff --git a/stingray/pulse/tests/test_modeling.py b/stingray/pulse/tests/test_modeling.py
index 5660da95..fa947504 100644
--- a/stingray/pulse/tests/test_modeling.py
+++ b/stingray/pulse/tests/test_modeling.py
@@ -1,5 +1,5 @@
 import numpy as np
-from stingray.pulse.modeling import fit_sinc, fit_gaussian
+from stingray.pulse.modeling import fit_sinc, fit_gaussian, SincSquareModel
 
 np.random.seed(0)
 
@@ -82,3 +82,13 @@ def test_gaussian_tied():
     gs = fit_gaussian(x, y, tied={"mean": tiedgaussian})
 
     assert np.abs(gs.mean/gs.amplitude - 0.5) < 0.1
+
+
+def test_pickle_SincSquared():
+    import pickle
+    a = SincSquareModel(amplitude=13., mean=3, width=12.)
+    pickle.dump(a, open('bubufile.p', 'wb'))
+    b = pickle.load(open('bubufile.p', 'rb'))
+    assert a.amplitude == b.amplitude
+    assert a.mean == b.mean
+    assert a.width == b.width
Repository: StingraySoftware/stingray
Pull request #284 (2017-12-04 16:28:07)

Fix rms error
The error bar in the rms spectrum was evidently wrong, because it was assuming the _power_ instead of the _power error_ in the squared sum.
Now it should be correct.


Patch:
diff --git a/stingray/varenergyspectrum.py b/stingray/varenergyspectrum.py
index 130b6a84..8fe17998 100644
--- a/stingray/varenergyspectrum.py
+++ b/stingray/varenergyspectrum.py
@@ -201,7 +201,7 @@ class RmsEnergySpectrum(VarEnergySpectrum):
                 rms_spec[i] = np.sqrt(np.sum(xspect.power[good]*xspect.df))
 
                 # Root squared sum of errors of the spectrum
-                root_sq_err_sum = np.sqrt(np.sum(xspect.power[good]**2))*xspect.df
+                root_sq_err_sum = np.sqrt(np.sum((xspect.power_err[good]*xspect.df)**2))
                 # But the rms is the squared root. So,
                 # Error propagation
                 rms_spec_err[i] = 1 / (2 * rms_spec[i]) * root_sq_err_sum


Test patch:
diff --git a/stingray/tests/test_varenergyspectrum.py b/stingray/tests/test_varenergyspectrum.py
index 827e9b43..07a6ff1b 100644
--- a/stingray/tests/test_varenergyspectrum.py
+++ b/stingray/tests/test_varenergyspectrum.py
@@ -157,11 +157,7 @@ class TestRMSEnergySpectrum(object):
         assert np.allclose(self.rms.spectrum, 0.4, 0.05)
 
     def test_correct_rms_errorbars(self):
-
-        # Assert that the rms measured at all energies is the same
-        assert np.all(
-            np.abs(self.rms.spectrum - self.rms.spectrum[0]) < \
-                self.rms.spectrum_error)
+        assert np.allclose(self.rms.spectrum_error, 0.0014, atol=0.0001)
 
     def test_rms_invalid_evlist_warns(self):
         ev = EventList(time=[], energy=[], gti=self.rms.events1.gti)