Skip to content

Commit 113cbf8

Browse files
authored
Merge pull request #34 from yoshoku/support_ruby2.7
Support for keyword argument of Ruby 2.7
2 parents c0d7f39 + aad7cbb commit 113cbf8

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rvm:
1010
- '2.4'
1111
- '2.5'
1212
- '2.6'
13+
- '2.7'
1314

1415
matrix:
1516
fast_finish:
@@ -28,9 +29,9 @@ before_install:
2829
- gem install --no-document bundler -v '~> 2.0'
2930

3031
install:
31-
- bundle install --jobs=3 --retry=3
3232
- gem install specific_install
3333
- gem specific_install https://github.com/ruby-numo/numo-narray
34+
- bundle install --jobs=3 --retry=3
3435

3536
script:
3637
- gem build numo-linalg.gemspec

lib/numo/linalg/function.rb

+18-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ module Blas
1212
# defined from data-types of arguments.
1313
# @param [Symbol] func function name without BLAS char.
1414
# @param args arguments passed to Blas function.
15+
# @param kwargs keyword arguments passed to Blas function.
1516
# @example
1617
# c = Numo::Linalg::Blas.call(:gemm, a, b)
17-
def self.call(func,*args)
18+
def self.call(func, *args, **kwargs)
1819
fn = (Linalg.blas_char(*args) + func.to_s).to_sym
1920
fn = FIXNAME[fn] || fn
20-
send(fn,*args)
21+
if kwargs.empty?
22+
# This conditional branch is necessary to prevent ArgumentError
23+
# that occurs in Ruby 2.6 or earlier.
24+
send(fn, *args)
25+
else
26+
send(fn, *args, **kwargs)
27+
end
2128
end
2229

2330
end
@@ -34,12 +41,19 @@ module Lapack
3441
# defined from data-types of arguments.
3542
# @param [Symbol,String] func function name without BLAS char.
3643
# @param args arguments passed to Lapack function.
44+
# @param kwargs keyword arguments passed to Lapack function.
3745
# @example
3846
# s = Numo::Linalg::Lapack.call(:gesv, a)
39-
def self.call(func,*args)
47+
def self.call(func, *args, **kwargs)
4048
fn = (Linalg.blas_char(*args) + func.to_s).to_sym
4149
fn = FIXNAME[fn] || fn
42-
send(fn,*args)
50+
if kwargs.empty?
51+
# This conditional branch is necessary to prevent ArgumentError
52+
# that occurs in Ruby 2.6 or earlier.
53+
send(fn, *args)
54+
else
55+
send(fn, *args, **kwargs)
56+
end
4357
end
4458

4559
end

0 commit comments

Comments
 (0)