Skip to content

Commit

Permalink
fixes for firecrown v.1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Sanchez authored and Javier Sanchez committed Feb 15, 2024
1 parent d8b6537 commit 34f4527
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 14 deletions.
10 changes: 7 additions & 3 deletions augur/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def f(self, x, labels, pars_fid, sys_fid):
self.tools.reset()
self.lk.reset()
cosmo = ccl.Cosmology(**_pars)
self.lk.update(ParamsMap(_sys_pars))
pmap = ParamsMap(_sys_pars)
self.lk.update(pmap)
self.tools.update(pmap)
self.tools.prepare(cosmo)
f_out = self.lk.compute_theory_vector(self.tools)
elif x.ndim == 2:
Expand All @@ -146,8 +148,10 @@ def f(self, x, labels, pars_fid, sys_fid):
raise ValueError(f'Parameter name {labels[j]} not recognized')
self.tools.reset()
self.lk.reset()
self.lk.update(ParamsMap(_sys_pars))
pmap = ParamsMap(_sys_pars)
self.lk.update(pmap)
cosmo = ccl.Cosmology(**_pars)
self.tools.update(pmap)
self.tools.prepare(cosmo)
f_out.append(self.lk.compute_theory_vector(self.tools))
return np.array(f_out)
Expand Down Expand Up @@ -196,7 +200,7 @@ def compute_fisher_bias(self):
# and the same length
import os
_calculate_biased_cls = True
_cls_fid = self.lk.measured_data_vector # Get the fiducial data vector
_cls_fid = self.lk.get_data_vector() # Get the fiducial data vector

# Try to read the biased data vector
if 'biased_dv' in self.config['fisher_bias']:
Expand Down
16 changes: 6 additions & 10 deletions augur/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def generate_sacc_and_stats(config):
return S, cosmo, stats, sys_params


def generate(config, return_all_outputs=False, write_sacc=True, force_read=True):
def generate(config, return_all_outputs=False, write_sacc=True):
"""
Generate likelihood object and sacc file with fiducial cosmology
Expand All @@ -267,10 +267,7 @@ def generate(config, return_all_outputs=False, write_sacc=True, force_read=True)
likelihood object.
write_sacc : bool
If `True` it writes a sacc file with fiducial data vector.
force_read : bool
If `True` it repopulates the likelihood data vector with the contents of the Sacc file
generated here. Note: For high-condition covariances where the Cholesky decomposition
fails, setting force_read to `True` may result in a `LinAlgError`.
Returns:
-------
Expand Down Expand Up @@ -307,6 +304,7 @@ def generate(config, return_all_outputs=False, write_sacc=True, force_read=True)
cosmo.compute_nonlin_power()
tools = ModelingTools(pt_calculator=pt_calculator)
lk.update(sys_params)
tools.update(sys_params)
tools.prepare(cosmo)
# Run the likelihood (to get the theory)
lk.compute_loglike(tools)
Expand All @@ -320,7 +318,7 @@ def generate(config, return_all_outputs=False, write_sacc=True, force_read=True)
st = st.statistic
st.ready = False
S.add_ell_cl(st.sacc_data_type, st.sacc_tracers[0], st.sacc_tracers[1],
st.ell_or_theta_, st.predicted_statistic_)
st.ell_or_theta_, st.get_theory_vector())
if config['cov_options']['cov_type'] == 'gaus_internal':
fsky = config['cov_options']['fsky']
cov = get_gaus_cov(S, lk, cosmo, fsky, config)
Expand Down Expand Up @@ -382,9 +380,7 @@ def generate(config, return_all_outputs=False, write_sacc=True, force_read=True)
print(config['fiducial_sacc_path'])
S.save_fits(config['fiducial_sacc_path'], overwrite=True)
# Update covariance and inverse -- TODO need to update cholesky!!
if force_read:
# Hacky way to overwrite...
lk.read(S)
lk.measured_data_vector = lk.get_data_vector()
lk = ConstGaussian(statistics=stats)
lk.read(S)
if return_all_outputs:
return lk, S, tools, sys_params
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies:
- flake8
- pip:
- tjpcov
- qp
- qp-prob
71 changes: 71 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[MAIN]

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs=0

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.9

# Discover python modules and packages in the file system subtree.
recursive=yes

# Add custom pylint plugins
# load-plugins=pylint_plugins.duplicate_code

[MESSAGES CONTROL]

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
disable=too-few-public-methods

[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME

[BASIC]

# Naming style matching correct argument names.
argument-naming-style=any

# Naming style matching correct attribute names.
attr-naming-style=any

# Naming style matching correct variable names.
variable-naming-style=any

# Naming style matching correct module level constants names.
const-naming-style=any

# Naming style matching correct method names.
method-naming-style=any

# Naming style matching correct function names.
function-naming-style=any

[STRING]

# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=yes

[TYPECHECK]

# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=false

[FORMAT]

# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=LF

[DESIGN]
max-args=20
max-attributes=20

0 comments on commit 34f4527

Please sign in to comment.