diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91064150..430790cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,14 +5,12 @@ on: [push, pull_request] jobs: MRI: name: ${{ matrix.os }} ruby-${{ matrix.ruby }} - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os }}-latest strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-11, windows-2022] - ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', head] - include: - - { os: windows-2022 , ruby: mswin } + os: ['ubuntu', 'macos', 'windows'] + ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head] steps: - uses: actions/checkout@v4 - name: Set up Ruby ${{ matrix.ruby }} @@ -59,7 +57,7 @@ jobs: sudo apt-get -y install podman podman pull fedora:rawhide - name: Get source - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'numo-narray' - name: Create container and run tests @@ -75,6 +73,7 @@ jobs: echo 'RUN gem build numo-narray.gemspec' echo 'RUN gem install numo-narray-*.gem' echo 'RUN bundle install' + echo 'RUN bundle exec rake compile' echo 'RUN bundle exec rake test' } > podmanfile podman build --tag fedora_test -f ./podmanfile diff --git a/ext/numo/narray/ndloop.c b/ext/numo/narray/ndloop.c index 7a3b74c4..58cc0b52 100644 --- a/ext/numo/narray/ndloop.c +++ b/ext/numo/narray/ndloop.c @@ -56,7 +56,7 @@ typedef struct NA_MD_LOOP { VALUE reduce; VALUE loop_opt; ndfunc_t *ndfunc; - void (*loop_func)(); + void (*loop_func)(ndfunc_t *, struct NA_MD_LOOP *); } na_md_loop_t; #define LARG(lp,iarg) ((lp)->user.args[iarg]) diff --git a/ext/numo/narray/numo/types/xint_macro.h b/ext/numo/narray/numo/types/xint_macro.h index 1bd6e6b0..35b920b5 100644 --- a/ext/numo/narray/numo/types/xint_macro.h +++ b/ext/numo/narray/numo/types/xint_macro.h @@ -3,8 +3,9 @@ #define m_extract(x) m_data_to_num(*(dtype*)(x)) -#define m_from_double(x) (x) -#define m_from_real(x) (x) +/* Handle negative values consistently across platforms for unsigned integer types */ +#define m_from_double(x) ((x) < 0 ? (dtype)((long long)(x)) : (dtype)(x)) +#define m_from_real(x) ((x) < 0 ? (dtype)((long long)(x)) : (dtype)(x)) #define m_from_sint(x) (x) #define m_from_int32(x) (x) #define m_from_int64(x) (x) diff --git a/test/narray_test.rb b/test/narray_test.rb index da96c464..3a1e2a21 100644 --- a/test/narray_test.rb +++ b/test/narray_test.rb @@ -142,9 +142,9 @@ class NArrayTest < Test::Unit::TestCase assert { a.sum == 29 } if float_types.include?(dtype) assert { a.mean == 29.0/6 } - assert { a.var == 13.766666666666669 } - assert { a.stddev == 3.710345895825168 } - assert { a.rms == 5.901977069875258 } + assert_in_delta(a.var, 13.766666666666669, 1e-14) + assert_in_delta(a.stddev, 3.710345895825168, 1e-14) + assert_in_delta(a.rms, 5.901977069875258, 1e-14) end assert { a.dup.fill(12) == [12]*6 } assert { (a + 1) == [2,3,4,6,8,12] }