tukeyized 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +127 -0
- data/LICENSE.txt +21 -0
- data/LICENSES/MIT.txt +21 -0
- data/README.md +47 -0
- data/REUSE.toml +35 -0
- data/Rakefile +45 -0
- data/lib/tukeyized.rb +33 -0
- data/tukeyized.gemspec +25 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a85fe1e84b4973c73bcf9211b8fd1b660a5003ec9b82d0db1c0d4d1e8a483639
|
4
|
+
data.tar.gz: a01ed877eadd11adc308c0163b92f0c9ed11c28a00af20439e355466985bb5c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94fa4c38e6bb9d2ad05ccecbf3550f91b3b9e54bb7790a469fbe9aba3aca96924b505ad2e80c34acb1ede563c144a110fa57e28da374e4230a34d4eb0128b3b8
|
7
|
+
data.tar.gz: 7c4a594d25c0b42c24ae45656a8c34b8c73c494a13642cf8e9d7bf909ae78cf882a6a24ae3fb13bab04121b4da7d94d7e51c1fec3c9e99786d04fc841f4a8a25
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
gem 'mdl', '~>0.13', require: false
|
10
|
+
gem 'minitest', '~>5.25', require: false
|
11
|
+
gem 'minitest-reporters', '~>1.7', require: false
|
12
|
+
gem 'rake', '~>13.2', require: false
|
13
|
+
gem 'rubocop', '~>1.64', require: false
|
14
|
+
gem 'rubocop-minitest', '~>0.38', require: false
|
15
|
+
gem 'rubocop-performance', '~>1.25', require: false
|
16
|
+
gem 'rubocop-rake', '~>0.7', require: false
|
17
|
+
gem 'simplecov', '~>0.22', require: false
|
18
|
+
gem 'simplecov-cobertura', '~>3.0', require: false
|
19
|
+
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tukeyized (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.3)
|
11
|
+
builder (3.3.0)
|
12
|
+
chef-utils (18.8.11)
|
13
|
+
concurrent-ruby
|
14
|
+
concurrent-ruby (1.3.5)
|
15
|
+
docile (1.4.1)
|
16
|
+
ffi (1.17.2-x64-mingw-ucrt)
|
17
|
+
ffi-win32-extensions (1.0.4)
|
18
|
+
ffi
|
19
|
+
json (2.15.0)
|
20
|
+
kramdown (2.5.1)
|
21
|
+
rexml (>= 3.3.9)
|
22
|
+
kramdown-parser-gfm (1.1.0)
|
23
|
+
kramdown (~> 2.0)
|
24
|
+
language_server-protocol (3.17.0.5)
|
25
|
+
lint_roller (1.1.0)
|
26
|
+
mdl (0.13.0)
|
27
|
+
kramdown (~> 2.3)
|
28
|
+
kramdown-parser-gfm (~> 1.1)
|
29
|
+
mixlib-cli (~> 2.1, >= 2.1.1)
|
30
|
+
mixlib-config (>= 2.2.1, < 4)
|
31
|
+
mixlib-shellout
|
32
|
+
minitest (5.25.5)
|
33
|
+
minitest-reporters (1.7.1)
|
34
|
+
ansi
|
35
|
+
builder
|
36
|
+
minitest (>= 5.0)
|
37
|
+
ruby-progressbar
|
38
|
+
mixlib-cli (2.1.8)
|
39
|
+
mixlib-config (3.0.27)
|
40
|
+
tomlrb
|
41
|
+
mixlib-shellout (3.3.9)
|
42
|
+
chef-utils
|
43
|
+
mixlib-shellout (3.3.9-x64-mingw-ucrt)
|
44
|
+
chef-utils
|
45
|
+
ffi-win32-extensions (~> 1.0.3)
|
46
|
+
win32-process (~> 0.9)
|
47
|
+
wmi-lite (~> 1.0)
|
48
|
+
parallel (1.27.0)
|
49
|
+
parser (3.3.9.0)
|
50
|
+
ast (~> 2.4.1)
|
51
|
+
racc
|
52
|
+
prism (1.5.1)
|
53
|
+
racc (1.8.1)
|
54
|
+
rainbow (3.1.1)
|
55
|
+
rake (13.3.0)
|
56
|
+
regexp_parser (2.11.3)
|
57
|
+
rexml (3.4.4)
|
58
|
+
rubocop (1.81.1)
|
59
|
+
json (~> 2.3)
|
60
|
+
language_server-protocol (~> 3.17.0.2)
|
61
|
+
lint_roller (~> 1.1.0)
|
62
|
+
parallel (~> 1.10)
|
63
|
+
parser (>= 3.3.0.2)
|
64
|
+
rainbow (>= 2.2.2, < 4.0)
|
65
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
66
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
69
|
+
rubocop-ast (1.47.1)
|
70
|
+
parser (>= 3.3.7.2)
|
71
|
+
prism (~> 1.4)
|
72
|
+
rubocop-minitest (0.38.2)
|
73
|
+
lint_roller (~> 1.1)
|
74
|
+
rubocop (>= 1.75.0, < 2.0)
|
75
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
76
|
+
rubocop-performance (1.26.0)
|
77
|
+
lint_roller (~> 1.1)
|
78
|
+
rubocop (>= 1.75.0, < 2.0)
|
79
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
80
|
+
rubocop-rake (0.7.1)
|
81
|
+
lint_roller (~> 1.1)
|
82
|
+
rubocop (>= 1.72.1)
|
83
|
+
ruby-progressbar (1.13.0)
|
84
|
+
simplecov (0.22.0)
|
85
|
+
docile (~> 1.1)
|
86
|
+
simplecov-html (~> 0.11)
|
87
|
+
simplecov_json_formatter (~> 0.1)
|
88
|
+
simplecov-cobertura (3.1.0)
|
89
|
+
rexml
|
90
|
+
simplecov (~> 0.19)
|
91
|
+
simplecov-html (0.13.2)
|
92
|
+
simplecov_json_formatter (0.1.4)
|
93
|
+
tomlrb (2.0.3)
|
94
|
+
unicode-display_width (3.2.0)
|
95
|
+
unicode-emoji (~> 4.1)
|
96
|
+
unicode-emoji (4.1.0)
|
97
|
+
win32-process (0.10.0)
|
98
|
+
ffi (>= 1.0.0)
|
99
|
+
wmi-lite (1.0.7)
|
100
|
+
yard (0.9.37)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
aarch64-linux
|
104
|
+
arm-linux
|
105
|
+
arm64-darwin
|
106
|
+
arm64-darwin-23
|
107
|
+
x64-mingw-ucrt
|
108
|
+
x86-linux
|
109
|
+
x86_64-darwin
|
110
|
+
x86_64-linux
|
111
|
+
|
112
|
+
DEPENDENCIES
|
113
|
+
mdl (~> 0.13)
|
114
|
+
minitest (~> 5.25)
|
115
|
+
minitest-reporters (~> 1.7)
|
116
|
+
rake (~> 13.2)
|
117
|
+
rubocop (~> 1.64)
|
118
|
+
rubocop-minitest (~> 0.38)
|
119
|
+
rubocop-performance (~> 1.25)
|
120
|
+
rubocop-rake (~> 0.7)
|
121
|
+
simplecov (~> 0.22)
|
122
|
+
simplecov-cobertura (~> 3.0)
|
123
|
+
tukeyized!
|
124
|
+
yard (~> 0.9)
|
125
|
+
|
126
|
+
BUNDLED WITH
|
127
|
+
2.5.16
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSES/MIT.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Remove Array Elements Using Tukey's Method
|
2
|
+
|
3
|
+
[](https://www.rultor.com/p/yegor256/tukeyized)
|
4
|
+
[](https://www.jetbrains.com/ruby/)
|
5
|
+
|
6
|
+
[](https://github.com/yegor256/tukeyized/actions/workflows/rake.yml)
|
7
|
+
[](https://www.0pdd.com/p?name=yegor256/tukeyized)
|
8
|
+
[](https://badge.fury.io/rb/tukeyized)
|
9
|
+
[](https://codecov.io/github/yegor256/tukeyized?branch=master)
|
10
|
+
[](https://rubydoc.info/github/yegor256/tukeyized/master/frames)
|
11
|
+
[](https://hitsofcode.com/view/github/yegor256/tukeyized)
|
12
|
+
[](https://github.com/yegor256/tukeyized/blob/master/LICENSE.txt)
|
13
|
+
|
14
|
+
This gem adds a simple `tukeyized` to the `Array` class.
|
15
|
+
The method returns a copy of the array without extreme values.
|
16
|
+
It uses the [Tukey's method].
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
require 'tukeyized'
|
20
|
+
puts [1, 6, 3, 8888, 3, 2, 8, -19292].tukeyized
|
21
|
+
```
|
22
|
+
|
23
|
+
Prints:
|
24
|
+
|
25
|
+
```text
|
26
|
+
1, 6, 3, 3, 2, 8
|
27
|
+
```
|
28
|
+
|
29
|
+
That's it.
|
30
|
+
|
31
|
+
## How to contribute
|
32
|
+
|
33
|
+
Read
|
34
|
+
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
35
|
+
Make sure your build is green before you contribute
|
36
|
+
your pull request. You will need to have
|
37
|
+
[Ruby](https://www.ruby-lang.org/en/) 3.0+ and
|
38
|
+
[Bundler](https://bundler.io/) installed. Then:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
bundle update
|
42
|
+
bundle exec rake
|
43
|
+
```
|
44
|
+
|
45
|
+
If it's clean and you don't see any error messages, submit your pull request.
|
46
|
+
|
47
|
+
[Tukey's method]: https://en.wikipedia.org/wiki/Tukey%27s_range_test
|
data/REUSE.toml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
|
4
|
+
version = 1
|
5
|
+
[[annotations]]
|
6
|
+
path = [
|
7
|
+
".DS_Store",
|
8
|
+
".gitattributes",
|
9
|
+
".gitignore",
|
10
|
+
".pdd",
|
11
|
+
"**.json",
|
12
|
+
"**.md",
|
13
|
+
"**.png",
|
14
|
+
"**.txt",
|
15
|
+
"**/.DS_Store",
|
16
|
+
"**/.gitignore",
|
17
|
+
"**/.pdd",
|
18
|
+
"**/*.csv",
|
19
|
+
"**/*.jpg",
|
20
|
+
"**/*.json",
|
21
|
+
"**/*.md",
|
22
|
+
"**/*.pdf",
|
23
|
+
"**/*.png",
|
24
|
+
"**/*.svg",
|
25
|
+
"**/*.txt",
|
26
|
+
"**/*.vm",
|
27
|
+
"**/CNAME",
|
28
|
+
"**/Gemfile.lock",
|
29
|
+
"Gemfile.lock",
|
30
|
+
"README.md",
|
31
|
+
"renovate.json",
|
32
|
+
]
|
33
|
+
precedence = "override"
|
34
|
+
SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
|
35
|
+
SPDX-License-Identifier = "MIT"
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
|
10
|
+
def name
|
11
|
+
@name ||= File.basename(Dir['*.gemspec'].first, '.*')
|
12
|
+
end
|
13
|
+
|
14
|
+
def version
|
15
|
+
Gem::Specification.load(Dir['*.gemspec'].first).version
|
16
|
+
end
|
17
|
+
|
18
|
+
task default: %i[clean test rubocop mdl yard]
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
desc 'Run all unit tests'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.warning = true
|
27
|
+
test.verbose = false
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'yard'
|
31
|
+
desc 'Build Yard documentation'
|
32
|
+
YARD::Rake::YardocTask.new do |t|
|
33
|
+
t.files = ['lib/**/*.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rubocop/rake_task'
|
37
|
+
desc 'Run RuboCop on all directories'
|
38
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
39
|
+
task.fail_on_error = true
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Run MarkdownLint (mdl) on all Markdown files'
|
43
|
+
task :mdl do
|
44
|
+
sh 'mdl README.md'
|
45
|
+
end
|
data/lib/tukeyized.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
# Array.
|
7
|
+
#
|
8
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
9
|
+
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
10
|
+
# License:: MIT
|
11
|
+
class Array
|
12
|
+
# Removes extreme values.
|
13
|
+
#
|
14
|
+
# @return [Array] New array
|
15
|
+
def tukeyized
|
16
|
+
return [] if empty?
|
17
|
+
percentile = lambda do |a, x|
|
18
|
+
k = (x / 100.0) * (a.length - 1)
|
19
|
+
f = k.floor
|
20
|
+
c = k.ceil
|
21
|
+
return a[k.to_i] if f == c
|
22
|
+
a[f] + ((a[c] - a[f]) * (k - f))
|
23
|
+
end
|
24
|
+
a = sort
|
25
|
+
a.size
|
26
|
+
q1 = percentile.call(a, 25)
|
27
|
+
q3 = percentile.call(a, 75)
|
28
|
+
iqr = q3 - q1
|
29
|
+
lower = q1 - (1.5 * iqr)
|
30
|
+
upper = q3 + (1.5 * iqr)
|
31
|
+
select { |x| x.between?(lower, upper) }
|
32
|
+
end
|
33
|
+
end
|
data/tukeyized.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require 'English'
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
10
|
+
s.required_ruby_version = '>=3.2'
|
11
|
+
s.name = 'tukeyized'
|
12
|
+
s.version = '0.0.1'
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.summary = '...'
|
15
|
+
s.description =
|
16
|
+
'...'
|
17
|
+
s.authors = ['Yegor Bugayenko']
|
18
|
+
s.email = 'yegor256@gmail.com'
|
19
|
+
s.homepage = 'https://github.com/yegor256/tukeyized'
|
20
|
+
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
21
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
s.rdoc_options = ['--charset=UTF-8']
|
23
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
24
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tukeyized
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yegor Bugayenko
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
12
|
+
description: "..."
|
13
|
+
email: yegor256@gmail.com
|
14
|
+
executables: []
|
15
|
+
extensions: []
|
16
|
+
extra_rdoc_files:
|
17
|
+
- LICENSE.txt
|
18
|
+
- README.md
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- Gemfile.lock
|
22
|
+
- LICENSE.txt
|
23
|
+
- LICENSES/MIT.txt
|
24
|
+
- README.md
|
25
|
+
- REUSE.toml
|
26
|
+
- Rakefile
|
27
|
+
- lib/tukeyized.rb
|
28
|
+
- tukeyized.gemspec
|
29
|
+
homepage: https://github.com/yegor256/tukeyized
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata:
|
33
|
+
rubygems_mfa_required: 'true'
|
34
|
+
rdoc_options:
|
35
|
+
- "--charset=UTF-8"
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.2'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubygems_version: 3.6.9
|
50
|
+
specification_version: 4
|
51
|
+
summary: "..."
|
52
|
+
test_files: []
|