magro 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c544837f96597012ff6cf938a4148b7fcc640237daf460ae26c64f91588767
4
- data.tar.gz: '08915ee5d2d4ed4b535963684b160e2ab4707d7823b56578f5574099ca33d7ad'
3
+ metadata.gz: 461bbd071fe195f5edc86daf605b89b021aa97a8164a060e2239f9c7eef57b77
4
+ data.tar.gz: 0dc546f4643257704deb3e31dbdf1d2dd0dc42405d35386babcab59c3ab618aa
5
5
  SHA512:
6
- metadata.gz: 4d5cd134c942319d0ecb83fb39b89cf8a42c3cacc9c4336eaf592b0170a4257e597ce5c62e4fdb35b4641f2446e206c79da4b012c009516547ff7ae464745975
7
- data.tar.gz: cd6cdb5059adf3ed20ea6b9625d314f0519c338b0f01b8abb1ea73ecb8c5cb183b0288e1cdbdb22482d8fb71945b26f4761911c606bb81ce62008cb3ee984742
6
+ metadata.gz: 19756e1ccb2b703de929a8c589e249442ae8901c12d095a8a9976c8e8c49593a55a6ba1267a1696cacbcbb15dc6a4d210cee11362854f8c72181a54ecb10f24a
7
+ data.tar.gz: 89695893f37e8e69cc2470a7e09f0b064f447df4293773218104b91a95a59033395d72f2a0b12bf1b83858841e3cefa7e8958c67206d2969f063bda411837260
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.1
2
+
3
+ - Refactor codes and configs with RuboCop.
4
+
1
5
  # 0.6.0
2
6
  - Reorganize native exntesion codes.
3
7
  - Remove dependent gem's type declaration file from installation files.
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/github/yoshoku/magro/badge.svg?branch=main)](https://coveralls.io/github/yoshoku/magro?branch=main)
5
5
  [![Gem Version](https://badge.fury.io/rb/magro.svg)](https://badge.fury.io/rb/magro)
6
6
  [![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/numo-liblinear/blob/main/LICENSE.txt)
7
- [![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/magro/doc/)
7
+ [![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/magro/doc/)
8
8
 
9
9
  Magro is a minimal image processing library in Ruby.
10
10
  Magro uses [Numo::NArray](https://github.com/ruby-numo/numo-narray) arrays as image objects and
@@ -59,7 +59,7 @@ Or install it yourself as:
59
59
  ## Contributing
60
60
 
61
61
  Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/magro.
62
- This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenant.org) code of conduct.
63
63
 
64
64
  ## License
65
65
 
data/lib/magro/filter.rb CHANGED
@@ -26,6 +26,7 @@ module Magro
26
26
  # @return [Numo::UInt8] (shape: [height, width, n_channels]) Filtered image.
27
27
  def filter2d(image, kernel, scale: nil, offset: 0)
28
28
  raise ArgumentError, 'Expect class of image to be Numo::NArray.' unless image.is_a?(Numo::NArray)
29
+
29
30
  filter_h, filter_w = kernel.shape
30
31
  padded = zero_padding(image, filter_h, filter_w)
31
32
  n_channels = image.shape[2]
@@ -46,11 +47,12 @@ module Magro
46
47
  # @param arr2 [Numo::NArray] (shape: [row2, col2]) Second input array.
47
48
  # @raise [ArgumentError] This error is raised when class of input array is not Numo::NArray.
48
49
  # @return [Numo::NArray] (shape: [row1 - row2 + 1, col1 - col2 + 1]) Convolution of arr1 with arr2.
49
- def convolve2d(arr1, arr2)
50
+ def convolve2d(arr1, arr2) # rubocop:disable Metrics/AbcSize
50
51
  raise ArgumentError, 'Expect class of first input array to be Numo::NArray.' unless arr1.is_a?(Numo::NArray)
51
52
  raise ArgumentError, 'Expect class of second input array to be Numo::NArray.' unless arr2.is_a?(Numo::NArray)
52
53
  raise ArgumentError, 'Expect first input array to be 2-dimensional array.' unless arr1.ndim == 2
53
54
  raise ArgumentError, 'Expect second input array to be 2-dimensional array.' unless arr2.ndim == 2
55
+
54
56
  row1, col1 = arr1.shape
55
57
  row2, col2 = arr2.shape
56
58
  # FIXME: lib/numo/narray/extra.rb:1098: warning: Using the last argument as keyword parameters is deprecated
@@ -61,7 +63,7 @@ module Magro
61
63
 
62
64
  # private
63
65
 
64
- def zero_padding(image, filter_h, filter_w)
66
+ def zero_padding(image, filter_h, filter_w) # rubocop:disable Metrics/AbcSize
65
67
  image_h, image_w, n_channels = image.shape
66
68
  pad_h = filter_h / 2
67
69
  pad_w = filter_w / 2
data/lib/magro/io.rb CHANGED
@@ -16,7 +16,7 @@ module Magro
16
16
  # @raise [IOError] This error is raised when failed to read image file.
17
17
  # @raise [NoMemoryError] If memory allocation of image data fails, this error is raised.
18
18
  # @return [Numo::UInt8] (shape: [height, width, n_channels]) Loaded image.
19
- def imread(filename)
19
+ def imread(filename) # rubocop:disable Metrics/AbcSize
20
20
  raise ArgumentError, 'Expect class of filename to be String.' unless filename.is_a?(String)
21
21
 
22
22
  unless url?(filename)
@@ -30,7 +30,7 @@ module Magro
30
30
 
31
31
  uri = URI.parse(filename)
32
32
  ext = File.extname(uri.path).downcase
33
- raise IOError, 'Failed to detect file extension from given URL.' unless ext =~ /\.(jpeg|jpg|jpe|png)$/
33
+ raise IOError, 'Failed to detect file extension from given URL.' unless /\.(jpeg|jpg|jpe|png)$/.match?(ext)
34
34
 
35
35
  uri.open do |file|
36
36
  temp = Tempfile.new(['magro_', ext])
@@ -55,7 +55,7 @@ module Magro
55
55
  raise ArgumentError, 'Expect class of filename to be String.' unless filename.is_a?(String)
56
56
  raise ArgumentError, 'Expect class of image to be Numo::NArray.' unless image.is_a?(Numo::NArray)
57
57
 
58
- if filename.downcase =~ /\.(jpeg|jpg|jpe)$/
58
+ if /\.(jpeg|jpg|jpe)$/.match?(filename.downcase)
59
59
  unless quality.nil?
60
60
  raise ArgumentError, 'Expect class of quality to be Numeric.' unless quality.is_a?(Numeric)
61
61
  raise ArgumentError, 'Range of quality value between 0 to 100.' unless quality.between?(0, 100)
@@ -63,7 +63,7 @@ module Magro
63
63
  return save_jpg(filename, image, quality)
64
64
  end
65
65
 
66
- return save_png(filename, image) if filename.downcase =~ /\.png$/
66
+ return save_png(filename, image) if /\.png$/.match?(filename.downcase)
67
67
 
68
68
  false
69
69
  end
@@ -32,7 +32,7 @@ module Magro
32
32
 
33
33
  # private
34
34
 
35
- def bilinear_resize(image, new_height, new_width)
35
+ def bilinear_resize(image, new_height, new_width) # rubocop:disable Metrics/AbcSize
36
36
  height, width = image.shape
37
37
 
38
38
  y_ratio = height.fdiv(new_height)
data/lib/magro/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Magro is an image processing library in Ruby.
4
4
  module Magro
5
5
  # The version of Magro you are using.
6
- VERSION = '0.6.0'
6
+ VERSION = '0.6.1'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -59,6 +59,7 @@ metadata:
59
59
  source_code_uri: https://github.com/yoshoku/magro
60
60
  changelog_uri: https://github.com/yoshoku/magro/blob/main/CHANGELOG.md
61
61
  documentation_uri: https://yoshoku.github.io/magro/doc/
62
+ rubygems_mfa_required: 'true'
62
63
  post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.3.3
78
+ rubygems_version: 3.2.33
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Magro is a minimal image processing library for Ruby.