Skip to content

Commit

Permalink
Adding another effective area weighting test (#53)
Browse files Browse the repository at this point in the history
* Adding another effective area weighting test

Adding a test for the weighted version of effective area with a lambda function for an E^-2.7 spectrum. Note the pdgid necessary for get_weights()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add ARG005 in ruff ignores

For the test of weighted effective area, I want to use lambda functions. The calculation of the integral of the flux demands a pdgid argument which however is actually not needed for a primary-independent flux weighting. So pdgid needs to be defined as argument of the flux function but not used which usually ruff would complain about.
I hope it's okay when I ignore ARG005

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jsaffer and pre-commit-ci[bot] authored Feb 20, 2025
1 parent 78dcd2c commit bedd1c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ select = ["ALL"]
"SLF001", # private-member-access
"PLR2004", # magic-value-comparison
"PLR0915", # too-many-statements
"S307" # suspicious-eval-usage
"S307", # suspicious-eval-usage
"ARG005" # unused function argument
]

[tool.ruff.lint.pydocstyle]
Expand Down
5 changes: 5 additions & 0 deletions tests/test_weighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ def test_effective_area(self):
149998.97822505102,
6,
)
self.assertAlmostEqual(
self.weighter1.effective_area([5e5, 5e6], [0, 1], flux=lambda energy, pdgid: energy ** (-2.7))[0][0],
149998.7936752823,
6,
)

with self.assertRaises(ValueError):
self.weighter1.effective_area([5e5, 5e6], [0, 1], flux="flux")
Expand Down

0 comments on commit bedd1c5

Please sign in to comment.