Skip to content

Commit

Permalink
Merge pull request #12 from probsys/20240225-fsaad-workflow
Browse files Browse the repository at this point in the history
20240225 fsaad workflow
  • Loading branch information
fsaad authored Feb 25, 2024
2 parents 4fb9c0b + c15c864 commit 195b4cd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ jobs:
make
./example.out
./examplef.out
# Auto-publish when version is increased
publish:
# Only try to publish if:
# * Repo is self (prevents running from forks)
# * Branch is `main`
if: |
github.repository == 'probsys/fast-loaded-dice-roller'
&& github.ref == 'refs/heads/master'
needs: build # Only publish after tests are successful
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 30

steps:
- uses: etils-actions/pypi-auto-publish@v1
with:
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
gh-token: ${{ secrets.GITHUB_TOKEN }}
parse-changelog: false
24 changes: 18 additions & 6 deletions src/c/flip.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@

#include "flip.h"

static int k = 30;
static int k = 31;
static int flip_word = 0;
static int flip_pos = 0;
static int flip_pos = 31;

int flip(void){
if (flip_pos == 0) {
if (flip_pos == k) {
flip_word = rand();
flip_pos = k;
flip_pos = 0;
}
--flip_pos;
return (flip_word >> flip_pos) & 1;
return (flip_word >> flip_pos++) & 1;
}

// Old implementation scans from lower-to-higher order bits,
// but rand() has poor quality on lower order bits.
// int flip(void){
// static int k = 31;
// static int flip_word = 0;
// static int flip_pos = 0;
// if (flip_pos == 0) {
// flip_word = rand();
// flip_pos = k;
// }
// return (flip_word >> --flip_pos) & 1;
// }
2 changes: 1 addition & 1 deletion src/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Released under Apache 2.0; refer to LICENSE.txt

__version__ = '1.4.6'
__version__ = '1.4.7'

from .fldr import fldr_preprocess_int
from .fldr import fldr_sample
Expand Down

0 comments on commit 195b4cd

Please sign in to comment.