Skip to content

Commit

Permalink
Increase anesthetic version + typos (#97)
Browse files Browse the repository at this point in the history
* change trivial things which have literally being hanging around for years

* bump version number

* update anesthetic syntax

* add anesthetic test

* remember how syntax works

* install correct anesthetic version

* check python version for anesthetic

* add spaces

* exclude 3.6 and 3.7

* put whole expression in brackets

* correct python version

* change to not contains

* put brackets in the right place

* change to single string

* correct silly version mistake
  • Loading branch information
AdamOrmondroyd committed Feb 28, 2023
1 parent 1854372 commit cfa26e4
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 115 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ jobs:

- name: Test pypolychord (MPI)
run: mpirun -np 2 python run_pypolychord.py

- name: Test pypolychord (anesthetic)
if: ${{ ! contains( '3.6, 3.7', matrix.python-version ) }}
run: |
pip install -r requirements.txt
python run_pypolychord.py
2 changes: 1 addition & 1 deletion Python_Functions/run_pypolychord_gaussian_shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def likelihood(theta):
r2 = 0


def logincexp(loga,logb,logx=None):
def logincexp(loga,logb,logc=None):
if (loga>logb):
loga = loga + log(exp(logb-loga) + 1)
else:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:target: https://arxiv.org/abs/1506.00171
:alt: Open-access paper

PolyChord v 1.20.1
PolyChord v 1.20.2

Will Handley, Mike Hobson & Anthony Lasenby

Expand Down
2 changes: 1 addition & 1 deletion pypolychord/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "1.20.1"
__version__ = "1.20.2"
from pypolychord.settings import PolyChordSettings
from pypolychord.polychord import run_polychord
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
scipy
anesthetic>=2.0.0b11
anesthetic>=2.0.0b19
131 changes: 38 additions & 93 deletions run_pypolychord.ipynb

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions run_pypolychord.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from numpy import pi, log, sqrt
from numpy import pi, log
import pypolychord
from pypolychord.settings import PolyChordSettings
from pypolychord.priors import UniformPrior
Expand Down Expand Up @@ -58,10 +58,11 @@ def dumper(live, dead, logweights, logZ, logZerr):

#| Make an anesthetic plot (could also use getdist)
try:
from anesthetic import NestedSamples
samples = NestedSamples(root= settings.base_dir + '/' + settings.file_root)
fig, axes = samples.plot_2d(['p0','p1','p2','p3','r'])
fig.savefig('posterior.pdf')
from matplotlib import pyplot as plt
from anesthetic import read_chains
samples = read_chains(settings.base_dir + '/' + settings.file_root)
samples.plot_2d(['p0','p1','p2','p3','r'])
plt.savefig('posterior.pdf')

except ImportError:
try:
Expand Down
24 changes: 12 additions & 12 deletions src/polychord/clustering.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module KNN_clustering
contains

!> This function returns a clustering from a similarity matrix based on
!! 'nearest neighbor' clustering.
!! 'nearest neighbour' clustering.
!!
!! Points belong to the same cluster if they are in either of each others k
!! nearest neighbor sets.
!!
!! The algorithm computes the k nearest neihbor sets from the similarity
!! The algorithm computes the k nearest neighbour sets from the similarity
!! matrix, and then tests
recursive function NN_clustering(similarity_matrix,num_clusters) result(cluster_list)
use utils_module, only: relabel
Expand Down Expand Up @@ -113,8 +113,8 @@ function do_clustering_k(knn) result(c)

! If they're not in the same cluster already...
if(c(i)/=c(j)) then
! ... check to see if they are within each others k nearest neihbors...
if( neighbors( knn(:,i),knn(:,j) ) ) then
! ... check to see if they are within each others k nearest neighbours...
if( neighbours( knn(:,i),knn(:,j) ) ) then

! If they are then relabel cluster_i and cluster_j to the smaller of the two
where(c==c(i).or.c==c(j))
Expand All @@ -137,10 +137,10 @@ function compute_knn(similarity_matrix,k) result(knn)
!> The data to compute on
real(dp), intent(in),dimension(:,:) :: similarity_matrix

!> The number of nearest neighbors to compute
!> The number of nearest neighbours to compute
integer, intent(in) :: k

! The indices of the k nearest neighbors to output
! The indices of the k nearest neighbours to output
integer, dimension(k,size(similarity_matrix,1)) :: knn

integer :: nPoints,i,j
Expand All @@ -154,7 +154,7 @@ function compute_knn(similarity_matrix,k) result(knn)
knn=0

do i=1,nPoints
! Find the k nearest neighbors for each point
! Find the k nearest neighbours for each point
distance2s = huge(1d0)
do j=1,nPoints
! If the distance between i and j is too large to be considered,
Expand All @@ -174,22 +174,22 @@ function compute_knn(similarity_matrix,k) result(knn)
end function compute_knn


! Return whether they're each others n nearest neighbor list
function neighbors(knn1,knn2) result(same_list)
! Return whether they're each others n nearest neighbour list
function neighbours(knn1,knn2) result(same_list)
implicit none
integer,intent(in), dimension(:) :: knn1
integer,intent(in), dimension(:) :: knn2

logical :: same_list

! Check to see if they're in each others neighbors lists
! Check to see if they're in each others neighbours lists
same_list= any(knn1==knn2(1)) .or. any(knn2==knn1(1))

end function neighbors
end function neighbours



! Return the number of matches in the n nearest neighbor list
! Return the number of matches in the n nearest neighbour list
function matches(knn1,knn2)
implicit none
integer,intent(in), dimension(:) :: knn1
Expand Down
2 changes: 1 addition & 1 deletion src/polychord/feedback.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine write_opening_statement(settings)
write(stdout_unit,'("")')
write(stdout_unit,'("PolyChord: Next Generation Nested Sampling")')
write(stdout_unit,'("copyright: Will Handley, Mike Hobson & Anthony Lasenby")')
write(stdout_unit,'(" version: 1.20.1")')
write(stdout_unit,'(" version: 1.20.2")')
write(stdout_unit,'(" release: 1st June 2021")')
write(stdout_unit,'(" email: wh260@mrao.cam.ac.uk")')
write(stdout_unit,'("")')
Expand Down

0 comments on commit cfa26e4

Please sign in to comment.