From 2167636fde80c97aab2c55b7c475a88a60556c81 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 24 May 2025 21:56:40 +0900 Subject: [PATCH 1/6] Update GitHub Actions workflow --- .github/workflows/build.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91064150..e196b2a2 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 }} From fb5d9e1ded6c02469501813f3616c64acdf171f6 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 24 May 2025 23:34:25 +0900 Subject: [PATCH 2/6] Add compilation step to Fedora Podman workflow --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e196b2a2..430790cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,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 @@ -73,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 From 8c1f8709f970646362256a7037a4ae438137e336 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 24 May 2025 22:49:26 +0900 Subject: [PATCH 3/6] Use assert_in_delta for floating-point comparisons --- test/narray_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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] } From f46527115ef3dfe5e14a340af4cff3b7a7cecd01 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 24 May 2025 23:15:40 +0900 Subject: [PATCH 4/6] Fix cross-platform negative value conversion for unsigned integer types --- ext/numo/narray/numo/types/xint_macro.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) From 421feddb46cac5145d69067fc1ac3ba3c434f668 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 24 May 2025 23:22:19 +0900 Subject: [PATCH 5/6] Fix function pointer declaration --- ext/numo/narray/ndloop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/numo/narray/ndloop.c b/ext/numo/narray/ndloop.c index 7a3b74c4..968d03c8 100644 --- a/ext/numo/narray/ndloop.c +++ b/ext/numo/narray/ndloop.c @@ -38,6 +38,8 @@ typedef struct NA_LOOP_XARGS { bool free_user_iter; // alloc LARG(lp,j).iter=lp->xargs[j].iter } na_loop_xargs_t; +typedef struct NA_MD_LOOP na_md_loop_t; + typedef struct NA_MD_LOOP { int narg; int nin; @@ -56,7 +58,7 @@ typedef struct NA_MD_LOOP { VALUE reduce; VALUE loop_opt; ndfunc_t *ndfunc; - void (*loop_func)(); + void (*loop_func)(ndfunc_t *, na_md_loop_t *); } na_md_loop_t; #define LARG(lp,iarg) ((lp)->user.args[iarg]) From 93d7ed065e1947ddc685828635bebb12ae5d44c4 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sun, 25 May 2025 13:42:40 +0900 Subject: [PATCH 6/6] Remove redundant typedef and fix self-reference in NA_MD_LOOP --- ext/numo/narray/ndloop.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/numo/narray/ndloop.c b/ext/numo/narray/ndloop.c index 968d03c8..58cc0b52 100644 --- a/ext/numo/narray/ndloop.c +++ b/ext/numo/narray/ndloop.c @@ -38,8 +38,6 @@ typedef struct NA_LOOP_XARGS { bool free_user_iter; // alloc LARG(lp,j).iter=lp->xargs[j].iter } na_loop_xargs_t; -typedef struct NA_MD_LOOP na_md_loop_t; - typedef struct NA_MD_LOOP { int narg; int nin; @@ -58,7 +56,7 @@ typedef struct NA_MD_LOOP { VALUE reduce; VALUE loop_opt; ndfunc_t *ndfunc; - void (*loop_func)(ndfunc_t *, na_md_loop_t *); + void (*loop_func)(ndfunc_t *, struct NA_MD_LOOP *); } na_md_loop_t; #define LARG(lp,iarg) ((lp)->user.args[iarg])