Skip to content

Commit

Permalink
updates for cobaya grids
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Oct 30, 2023
1 parent f755a38 commit 212482e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion getdist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = 'Antony Lewis'
__version__ = "1.4.5"
__version__ = "1.4.6"
__url__ = "https://getdist.readthedocs.io"

import os
Expand Down
33 changes: 22 additions & 11 deletions getdist/chain_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get_chain_root_files(rootdir):
files = [os.path.splitext(f)[0] for f in glob.glob(pattern)]
ending = 'updated.yaml'
pattern = os.path.join(rootdir, "*" + ending)
files += [f[:-len(ending)].rstrip("_.") for f in glob.glob(pattern)]
files += [f[:-len(ending)].rstrip("_.") for f in glob.glob(pattern)
if '.minimize.' not in f]
files = [f for f in files if hasChainFiles(os.path.join(rootdir, f))]
files.sort()
return files
Expand All @@ -34,15 +35,24 @@ def is_grid_object(obj):
def load_supported_grid(chain_dir):
if is_grid_object(chain_dir):
return chain_dir
try:
# If cosmomc is installed, e.g. to allow use of old Planck grids
# The 2018 final Planck grid should be OK with getdist default chain grid below
from paramgrid import gridconfig, batchjob
if gridconfig.pathIsGrid(chain_dir):
return batchjob.readobject(chain_dir)
except ImportError:
pass
return None
config_file = os.path.join(chain_dir, 'config', 'config.ini')
if os.path.exists(config_file):
grid_settings = IniFile(config_file)
if grid_settings.hasKey('cobaya_version'):
try:
from cobaya.grid_tools import batchjob
return batchjob.readobject(chain_dir)
except ImportError:
return None
else:
try:
# If cosmomc is installed, e.g. to allow use of old Planck grids
# The 2018 final Planck grid should be OK with getdist default chain grid below
from paramgrid import gridconfig, batchjob
if gridconfig.pathIsGrid(chain_dir):
return batchjob.readobject(chain_dir)
except ImportError:
return None


class ChainItem:
Expand Down Expand Up @@ -84,7 +94,8 @@ def __init__(self, base):
self._make_unique()

def normed_name(self, root):
return '_'.join(sorted(root.replace('__', '_').replace('_post', '').split('_')))
return '_'.join(sorted(root.replace('__', '_')
.replace('_post', '').replace('.post.', '_').split('_')))

def _add(self, dir_tag, dirname, roots):
self.base_dir_names.add(dir_tag)
Expand Down
4 changes: 2 additions & 2 deletions getdist/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,5 +922,5 @@ def loadFromFile(self, filename):
print('Error reading: ' + filename)
raise

def worstR(self):
return self.R_eigs[len(self.R_eigs) - 1]
def worstR(self, default=None):
return self.R_eigs[len(self.R_eigs) - 1] if self.R_eigs else default

0 comments on commit 212482e

Please sign in to comment.