Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix potential errors of the witting method #7

Merged
merged 4 commits into from
Jul 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
run: |
python -m pip list
- name: Check code format with pre-commit
uses: pre-commit/action@v3.0.0
uses: pre-commit/action@v3.0.1
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
python setup.py sdist bdist_wheel
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: dist
Expand All @@ -53,12 +53,12 @@ jobs:
uses: actions/checkout@v4
- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v3
uses: mikepenz/release-changelog-builder-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.changelog }}

Expand All @@ -73,7 +73,7 @@ jobs:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/random-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
fi
- name: Upload artifacts if artifacts directory is not empty
if : ${{ steps.check_artifacts_empty.outputs.is_empty == 'false' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ github.run_number }}
path: $ARTIFACTS_DIR
Expand Down
7 changes: 6 additions & 1 deletion diff_binom_confint/_binom_confint.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,12 @@ def _compute_confidence_interval(
elif confint_type.lower() == "witting":
# stochastic, checked by seeting n_pos_tilde = n_positive
# n_pos_tilde = n_positive
n_pos_tilde = n_positive + RNG.uniform(0, 1)
if n_positive == n_total:
n_pos_tilde = n_positive + RNG.uniform(0, 0.97)
elif n_positive == 0:
n_pos_tilde = n_positive + RNG.uniform(0.03, 1)
else:
n_pos_tilde = n_positive + RNG.uniform(0, 1)
return ConfidenceInterval(
_qbinom_abscont(_conf_level, n_total, n_pos_tilde) if n_positive != 0 else 0.0,
_qbinom_abscont(1 - _conf_level, n_total, n_pos_tilde) if n_positive != n_total else 1.0,
Expand Down
1 change: 1 addition & 0 deletions test/test_bci.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def test_reported_error_cases():
"""
error_cases = [
{"n_positive": 2, "n_total": 2, "method": "witting", "conf_level": 0.975}, # issue #5
{"n_positive": 0, "n_total": 850, "method": "witting", "conf_level": 0.975}, # issue #5
]

for case in error_cases:
Expand Down