diff --git a/augur/analyze.py b/augur/analyze.py index 1d228db..3a0adc6 100644 --- a/augur/analyze.py +++ b/augur/analyze.py @@ -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: @@ -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) @@ -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']: diff --git a/augur/generate.py b/augur/generate.py index fc94158..8e37a66 100644 --- a/augur/generate.py +++ b/augur/generate.py @@ -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 @@ -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: ------- @@ -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) @@ -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) @@ -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 diff --git a/environment.yml b/environment.yml index a3bafba..055fb6c 100644 --- a/environment.yml +++ b/environment.yml @@ -10,4 +10,4 @@ dependencies: - flake8 - pip: - tjpcov - - qp + - qp-prob diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..0e8627d --- /dev/null +++ b/pylintrc @@ -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