Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
coverage.xml
htmlcov/
.pytest_cache/
.hypothesis/
*.bai

# Backup files from some Unix editors
Expand Down
8 changes: 4 additions & 4 deletions cnvlib/descriptives.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ def weighted_median(a: ndarray, weights: ndarray) -> float64:
cumulative_weight = weights.cumsum()
midpoint_idx = cumulative_weight.searchsorted(midpoint)
if (
midpoint_idx > 0
and cumulative_weight[midpoint_idx - 1] - midpoint < sys.float_info.epsilon
midpoint_idx < len(a) - 1
and abs(cumulative_weight[midpoint_idx] - midpoint) < sys.float_info.epsilon
):
# Midpoint of 2 array values
return a[midpoint_idx - 1 : midpoint_idx + 1].mean() # type: ignore[no-any-return]
# Cumulative weight exactly at midpoint: average two adjacent values
return a[midpoint_idx : midpoint_idx + 2].mean() # type: ignore[no-any-return]
return a[midpoint_idx] # type: ignore[no-any-return]


Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
- pytest-cov
- pytest-xdist
- coverage
- hypothesis
- ruff
- safety
- bandit
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ optional-dependencies = {test = {file = "requirements/tests.txt"}}
testpaths = ["test"]
markers = [
"slow: tests that take >5 seconds (skip with -m 'not slow')",
"hypothesis: property-based tests using Hypothesis (skip with -m 'not hypothesis')",
]
filterwarnings = [
"error",
# bioframe <=0.8.0 uses df.groupby(['col']).groups with a single-element
# list, which pandas 3.0 deprecates via Pandas4Warning.
"ignore:In a future version, the keys of:Warning",
# Hypothesis internal warnings that would otherwise be promoted to errors
"ignore::hypothesis.errors.NonInteractiveExampleWarning",
]

[tool.coverage.run]
Expand Down
1 change: 1 addition & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pytest
pytest-cov
pytest-xdist
coverage[all]
hypothesis[numpy]
mypy
ruff
safety
Expand Down
Loading
Loading