diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index 3ed5fa9..d73ca16 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5eb6f54..38f5dfb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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 }} @@ -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 }} diff --git a/.github/workflows/random-test.yml b/.github/workflows/random-test.yml index 18016ac..601e3a7 100644 --- a/.github/workflows/random-test.yml +++ b/.github/workflows/random-test.yml @@ -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 diff --git a/diff_binom_confint/_binom_confint.py b/diff_binom_confint/_binom_confint.py index ef42061..884a4fd 100644 --- a/diff_binom_confint/_binom_confint.py +++ b/diff_binom_confint/_binom_confint.py @@ -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, diff --git a/test/test_bci.py b/test/test_bci.py index c2d24ab..60ce0e8 100644 --- a/test/test_bci.py +++ b/test/test_bci.py @@ -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: