Unverified Commit ea492a2c authored by Akke Viitanen's avatar Akke Viitanen
Browse files

add tests and fix existing ones

parent 38d78dec
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ _build
demo

.venv/
venv/
doc/
notebooks/
overleaf/
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ verbose: 1
out: data/catalog/test/egg.fits

# area in deg2
area: 0.10
area: 0.01

# right ascension of center
ra0: +150.11916667
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ install_imsim () {
    ## conda dependencies:
    # mamba install -y --file imSim/etc/standalone_conda_requirements.txt
    # mamba install rubin-sim
    #

    ## Install imSim:
    # pip install --no-deps imSim/
    # pip install --no-deps skyCatalogs/
+12 −7
Original line number Diff line number Diff line
@@ -15,16 +15,23 @@ classifiers = [
    "Programming Language :: Python",
]
dynamic = ["version"]
requires-python = ">=3.9"
#requires-python = ">=3.9"
requires-python = "==3.12.*"
dependencies = [
    "astropy",
    "batman-package@git+https://github.com/PriyadarshiAkshay/batman.git@py13", # fixes python3.12 issue
    "fitsio",
    "ipywidgets",
    "matplotlib",
    "numpy",
    "mypy",
    "numpy",
    "pandas",
    "pytest",
    "pytest-cov",
    "pyvo",
    "pre_commit",
    "scipy",
    "setuptools",
    "sphinx",
    "sphinx_rtd_theme",
    "sphinx-autoapi",
@@ -40,7 +47,6 @@ dependencies = [
dev = [
    "asv==0.6.4", # Used to compute performance benchmarks
    "jupyter", # Clears output from Jupyter notebooks
    "mypy", # Used for static type checking of files
    "pre-commit", # Used to run checks before finalizing a git commit
    "pytest",
    "pytest-cov", # Used to report total code coverage
@@ -66,11 +72,13 @@ testpaths = [
    "docs",
]
addopts = "--doctest-modules --doctest-glob=*.rst"
pythonpath = ['.', 'src']

[tool.ruff]
line-length = 110
target-version = "py39"
target-version = "py312"
exclude = ["etc/"]

[tool.ruff.lint]
select = [
    # pycodestyle
@@ -117,6 +125,3 @@ lsst_inaf_agile = ["py.typed"]

[tool.coverage.run]
omit=["src/lsst_inaf_agile/_version.py"]

[tool.mypy]
exclude = "src/scripts/butler/create_truth_summary.py"
+11 −15
Original line number Diff line number Diff line
@@ -14,19 +14,15 @@ from itertools import product

import astropy.units as u
import fitsio
import lightcurve
import lusso2010
import numpy as np
import pandas as pd
import sed
import ueda2014
import util
import zou2024
from catalog_galaxy import CatalogGalaxy
from mbh import get_log_mbh_continuity_new2
from merloni2014 import Merloni2014
from mock_catalog_SED.qsogen_4_catalog import qsosed
from util import ROOT

from lsst_inaf_agile import lightcurve, lusso2010, sed, ueda2014, util, zou2024
from lsst_inaf_agile.catalog_galaxy import CatalogGalaxy
from lsst_inaf_agile.mbh import get_log_mbh_continuity_new2
from lsst_inaf_agile.merloni2014 import Merloni2014
from lsst_inaf_agile.util import ROOT

logger = logging.getLogger(__name__)

@@ -330,7 +326,7 @@ class CatalogAGN:

        Uses Lusso+10 Eq. 5 (inverted) assuming Lx = alpha L_opt - beta
        """
        return lusso2010.get_log_l_2500(self["log_L_2_keV"], alpha, beta, scatter)
        return lusso2010.get_log_luminosity_2500(self["log_L_2_keV"], alpha, beta, scatter)

    def get_is_optical_type2(self, func_get_f_obs=None, use_f_obs_for_ctk_agn=False):
        """
@@ -372,8 +368,8 @@ class CatalogAGN:
        CTK AGN are assumed to be all type2.

        """
        type_1_ebv = (np.linspace(0, 1, 101),)
        type_2_ebv = (np.linspace(0, 3, 301),)
        type_1_ebv = np.linspace(0, 1, 101)
        type_2_ebv = np.linspace(0, 3, 301)

        def sample_ebv(N_AGN, probability_distribution, ebv_range, *args):
            cumulative = np.cumsum(probability_distribution(ebv_range, *args))
@@ -530,7 +526,7 @@ class CatalogAGN:
                add_NL=self["is_optical_type2"][i],
                NL_normalization="lamastra",
                Av_lines=self.catalog_galaxy["AVLINES_BULGE"][i] + self.catalog_galaxy["AVLINES_DISK"][i],
                **dict(zip(PARAMETER_NAMES, *POSTERIOR_DISTRIBUTION.sample().values)),
                **dict(zip(PARAMETER_NAMES, *POSTERIOR_DISTRIBUTION.sample().values, strict=False)),
            )

            # Check for type2 AGN flux NOT exceeding the host galaxy flux by
@@ -734,7 +730,7 @@ class CatalogAGN:
        The black hole occupation fraction applied here is based on Zou+2025
        (accepted).
        """
        from mbh import get_occupation_fraction
        from lsst_inaf_agile.mbh import get_occupation_fraction

        return get_occupation_fraction(self["M"])

Loading