Skip to content

Commit bedd1c5

Browse files
Adding another effective area weighting test (#53)
* 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>
1 parent 78dcd2c commit bedd1c5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ select = ["ALL"]
122122
"SLF001", # private-member-access
123123
"PLR2004", # magic-value-comparison
124124
"PLR0915", # too-many-statements
125-
"S307" # suspicious-eval-usage
125+
"S307", # suspicious-eval-usage
126+
"ARG005" # unused function argument
126127
]
127128

128129
[tool.ruff.lint.pydocstyle]

tests/test_weighter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ def test_effective_area(self):
217217
149998.97822505102,
218218
6,
219219
)
220+
self.assertAlmostEqual(
221+
self.weighter1.effective_area([5e5, 5e6], [0, 1], flux=lambda energy, pdgid: energy ** (-2.7))[0][0],
222+
149998.7936752823,
223+
6,
224+
)
220225

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

0 commit comments

Comments
 (0)