From f032b310fc676da5f0a595dab02d263d5e0e5579 Mon Sep 17 00:00:00 2001 From: "Sergey E. Koposov" Date: Fri, 5 Feb 2021 16:08:23 +0000 Subject: [PATCH 1/8] do not use signal handlers if threads are involved --- pymultinest/run.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pymultinest/run.py b/pymultinest/run.py index b072e4e..52b7cda 100644 --- a/pymultinest/run.py +++ b/pymultinest/run.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, unicode_literals, print_function from ctypes import cdll from ctypes.util import find_library -import sys, os +import sys, os, threading def _load_library(libname): libname = { @@ -201,6 +201,10 @@ def Loglike(cube, ndim, nparams, lnew): dumper_type = CFUNCTYPE(c_void_p, c_int, c_int, c_int, POINTER(c_double),POINTER(c_double),POINTER(c_double), c_double,c_double,c_double,c_void_p) + + # check if threads are involved + # in that case we can't use the signal handler + is_thread = threading.active_count() > 1 # check if lnew is supported by user function nargs = 3 @@ -234,7 +238,8 @@ def dumper(nSamples,nlive,nPar, as_array(posterior,shape=(nPar+2,nSamples)).T, (pc[:,0],pc[:,1],pc[:,2],pc[:,3]), # (mean,std,bestfit,map) maxLogLike,logZ,logZerr, 0) - prev_handler = signal.signal(signal.SIGINT, interrupt_handler) + if not is_thread: + prev_handler = signal.signal(signal.SIGINT, interrupt_handler) # to avoid garbage collection of these ctypes, which leads to NULLs # we need to make local copies here that are not thrown away @@ -275,7 +280,8 @@ def dumper(nSamples,nlive,nPar, MPI.COMM_WORLD.Barrier() else: lib.run(*args_converted) - signal.signal(signal.SIGINT, prev_handler) + if not is_thread: + signal.signal(signal.SIGINT, prev_handler) assert len(args) == len(argtypes) # to make sure stuff is still here def _is_newer(filea, fileb): From a86ec9e53f7375d7e1725bdf428a5a6006a1d96c Mon Sep 17 00:00:00 2001 From: Johannes Buchner Date: Mon, 26 Apr 2021 16:23:56 +0200 Subject: [PATCH 2/8] update link to doc --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 79d1d26..3fd9d96 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ The plotting can also be run on existing MultiNest output, and when not using Py Citing PyMultiNest -------------------------------------------- -See http://johannesbuchner.github.com/PyMultiNest/index.html#citing-pymultinest +See http://johannesbuchner.github.io/PyMultiNest/index.html#citing-pymultinest Plotting results, corner and trace plots -------------------------------------------- From e2f2e75bdb53d2f8dbd48874744cf4dd50e986e1 Mon Sep 17 00:00:00 2001 From: Johannes Buchner Date: Tue, 24 Aug 2021 11:30:45 +0200 Subject: [PATCH 3/8] fix link to docs --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3fd9d96..4cdeb76 100644 --- a/README.rst +++ b/README.rst @@ -88,7 +88,7 @@ This helps other people google the same question. Using MultiNest with Python? -------------------------------------------- -Look at the documentation available at http://johannesbuchner.github.com/PyMultiNest/index.html +Look at the documentation available at http://johannesbuchner.github.io/PyMultiNest/ What is PyCuba? -------------------------------------------- From 8c364d257633f238e9684e9f4161771dfbb6c111 Mon Sep 17 00:00:00 2001 From: Warrick Ball Date: Fri, 20 May 2022 10:15:53 +0100 Subject: [PATCH 4/8] correct URLs from http://johannesbuchner.github.com to https://johannesbuchner.github.io --- pymultinest/run.py | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pymultinest/run.py b/pymultinest/run.py index 52b7cda..6899794 100644 --- a/pymultinest/run.py +++ b/pymultinest/run.py @@ -21,20 +21,20 @@ def _load_library(libname): print('ERROR: Could not load MultiNest library "%s"' % libname) print('ERROR: You have to build it first,') print('ERROR: and point the LD_LIBRARY_PATH environment variable to it!') - print('ERROR: manual: http://johannesbuchner.github.com/PyMultiNest/install.html') + print('ERROR: manual: https://johannesbuchner.github.io/PyMultiNest/install.html') print() if message.endswith('cannot open shared object file: No such file or directory'): print() print('ERROR: Could not load MultiNest library: %s' % message.split(':')[0]) print('ERROR: You have to build MultiNest,') print('ERROR: and point the LD_LIBRARY_PATH environment variable to it!') - print('ERROR: manual: http://johannesbuchner.github.com/PyMultiNest/install.html') + print('ERROR: manual: https://johannesbuchner.github.io/PyMultiNest/install.html') print() if 'undefined symbol: mpi_' in message: print() print('ERROR: You tried to compile MultiNest linked with MPI,') print('ERROR: but now when running, MultiNest can not find the MPI linked libraries.') - print('ERROR: manual: http://johannesbuchner.github.com/PyMultiNest/install.html') + print('ERROR: manual: https://johannesbuchner.github.io/PyMultiNest/install.html') print() # the next if is useless because we can not catch symbol lookup errors (the executable crashes) # but it is still there as documentation. @@ -43,7 +43,7 @@ def _load_library(libname): print('ERROR: You are trying to get MPI to run, but MPI failed to load.') print('ERROR: Specifically, mpi symbols are missing in the executable.') print('ERROR: Let me know if this is a problem of running python or a compilation problem.') - print('ERROR: manual: http://johannesbuchner.github.com/PyMultiNest/install.html') + print('ERROR: manual: https://johannesbuchner.github.io/PyMultiNest/install.html') print() # what if built with MPI, but don't have MPI print('problem:', e) diff --git a/setup.py b/setup.py index df4a033..b3fefda 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ author_email = "johannes.buchner.acad@gmx.com", maintainer = "Johannes Buchner", maintainer_email = "johannes.buchner.acad@gmx.com", - url = "http://johannesbuchner.github.com/PyMultiNest/", + url = "https://johannesbuchner.github.io/PyMultiNest/", license = "GPLv3", packages = ["pymultinest", "pycuba"], provides = ["pymultinest", "pycuba"], From 38ba50092dda1869d4f0aba54a40c9bf7545af4a Mon Sep 17 00:00:00 2001 From: Ormorod Date: Mon, 10 Oct 2022 17:56:09 +0100 Subject: [PATCH 5/8] add .eggs to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1a99b60..d615e4c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ build dist doc/_build *.egg-info +.eggs From 3b1648702ddcf48c68bd24c4f836c2650e24c038 Mon Sep 17 00:00:00 2001 From: Ormorod Date: Mon, 10 Oct 2022 18:03:31 +0100 Subject: [PATCH 6/8] change incorrect basename -> outputfiles_basename --- pymultinest/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymultinest/run.py b/pymultinest/run.py index 6899794..97f10a1 100644 --- a/pymultinest/run.py +++ b/pymultinest/run.py @@ -296,9 +296,9 @@ def multinest_complete(outputfiles_basename = "chains/1-"): """ names = ['stats.dat', 'post_equal_weights.dat', '.txt', 'resume.dat', 'params.json'] for n in names: - if not os.path.exists(basename + n): + if not os.path.exists(outputfiles_basename + n): return False # if stats.dat and post_equal_weights.dat are newer than .txt and resume.dat exists - if not _is_newer(basename + 'post_equal_weights.dat', basename + '.txt'): + if not _is_newer(outputfiles_basename + 'post_equal_weights.dat', outputfiles_basename + '.txt'): return False return True From e543962de8b67d7d821e01657686e41ceb2b508c Mon Sep 17 00:00:00 2001 From: Colm Talbot Date: Mon, 16 Jan 2023 14:53:05 -0500 Subject: [PATCH 7/8] deprecation removal getargspec -> getfullargspec --- pymultinest/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymultinest/run.py b/pymultinest/run.py index 97f10a1..39c81ba 100644 --- a/pymultinest/run.py +++ b/pymultinest/run.py @@ -209,7 +209,7 @@ def Loglike(cube, ndim, nparams, lnew): # check if lnew is supported by user function nargs = 3 try: - nargs = len(inspect.getargspec(LogLikelihood).args) - inspect.ismethod(LogLikelihood) + nargs = len(inspect.getfullargspec(LogLikelihood).args) - inspect.ismethod(LogLikelihood) except: pass From 46ed095d8024b700ddb7ddd4a2df8a8f751a6c32 Mon Sep 17 00:00:00 2001 From: Tuomo Salmi Date: Wed, 8 Feb 2023 14:54:22 +0100 Subject: [PATCH 8/8] Python2 compatibility returned --- pymultinest/run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pymultinest/run.py b/pymultinest/run.py index 39c81ba..a8f0137 100644 --- a/pymultinest/run.py +++ b/pymultinest/run.py @@ -209,7 +209,10 @@ def Loglike(cube, ndim, nparams, lnew): # check if lnew is supported by user function nargs = 3 try: - nargs = len(inspect.getfullargspec(LogLikelihood).args) - inspect.ismethod(LogLikelihood) + if sys.version_info[0] == 3: + nargs = len(inspect.getfullargspec(LogLikelihood).args) - inspect.ismethod(LogLikelihood) + else: + nargs = len(inspect.getargspec(LogLikelihood).args) - inspect.ismethod(LogLikelihood) except: pass