Skip to content

Commit 7102f02

Browse files
committed
Rename stddev -> stdev
1 parent 75a7b39 commit 7102f02

4 files changed

Lines changed: 50 additions & 50 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ The following methods are supplied by this library:
3434
- Calculates a mean of values in an array or an enumerable
3535
- `Array#variance`, `Enumerable#variance`
3636
- Calculates a variance of values in an array or an enumerable
37-
- `Array#stddev`, `Enumerable#stddev`
37+
- `Array#stdev`, `Enumerable#stdev`
3838
- Calculates a standard deviation of values in an array or an enumerable
3939
- `Array#mean_variance`, `Enumerable#mean_variance`
4040
- Calculates a mean and a variance simultaneously
41-
- `Array#mean_stddev`, `Enumerable#mean_stddev`
41+
- `Array#mean_stdev`, `Enumerable#mean_stdev`
4242
- Calculates a mean and a standard deviation simultaneously
4343

4444
Moreover, for Ruby < 2.4, `Array#sum` and `Enumerable#sum` are provided.

ext/enumerable/statistics/extension/statistics.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ sqrt_value(VALUE x)
13801380
}
13811381

13821382
/* call-seq:
1383-
* enum.mean_stddev(population: false)
1383+
* enum.mean_stdev(population: false)
13841384
*
13851385
* Calculate a mean and a standard deviation of the values in `enum`.
13861386
* The first element of the result array is the mean,
@@ -1389,16 +1389,16 @@ sqrt_value(VALUE x)
13891389
* This method is equivalent to:
13901390
*
13911391
* ```ruby
1392-
* def mean_stddev(population: false)
1392+
* def mean_stdev(population: false)
13931393
* m, v = mean_variance(population: population)
13941394
* [m, Math.sqrt(v)]
13951395
* end
13961396
* ```
13971397
*
1398-
* @return (mean, stddev)
1398+
* @return (mean, stdev)
13991399
*/
14001400
static VALUE
1401-
enum_mean_stddev(int argc, VALUE* argv, VALUE obj)
1401+
enum_mean_stdev(int argc, VALUE* argv, VALUE obj)
14021402
{
14031403
VALUE opts, mean, variance;
14041404
size_t ddof = 1;
@@ -1408,12 +1408,12 @@ enum_mean_stddev(int argc, VALUE* argv, VALUE obj)
14081408
ddof = 0;
14091409

14101410
enum_mean_variance(obj, &mean, &variance, ddof);
1411-
VALUE stddev = sqrt_value(variance);
1412-
return rb_assoc_new(mean, stddev);
1411+
VALUE stdev = sqrt_value(variance);
1412+
return rb_assoc_new(mean, stdev);
14131413
}
14141414

14151415
/* call-seq:
1416-
* enum.stddev(population: false)
1416+
* enum.stdev(population: false)
14171417
*
14181418
* Calculate a standard deviation of the values in `enum`.
14191419
*
@@ -1426,15 +1426,15 @@ enum_mean_stddev(int argc, VALUE* argv, VALUE obj)
14261426
* @return [Number] A standard deviation value
14271427
*/
14281428
static VALUE
1429-
enum_stddev(int argc, VALUE* argv, VALUE obj)
1429+
enum_stdev(int argc, VALUE* argv, VALUE obj)
14301430
{
14311431
VALUE variance = enum_variance(argc, argv, obj);
1432-
VALUE stddev = sqrt_value(variance);
1433-
return stddev;
1432+
VALUE stdev = sqrt_value(variance);
1433+
return stdev;
14341434
}
14351435

14361436
/* call-seq:
1437-
* ary.mean_stddev(population: false)
1437+
* ary.mean_stdev(population: false)
14381438
*
14391439
* Calculate a mean and a standard deviation of the values in `ary`.
14401440
* The first element of the result array is the mean,
@@ -1443,16 +1443,16 @@ enum_stddev(int argc, VALUE* argv, VALUE obj)
14431443
* This method is equivalent to:
14441444
*
14451445
* ```ruby
1446-
* def mean_stddev(population: false)
1446+
* def mean_stdev(population: false)
14471447
* m, v = mean_variance(population: population)
14481448
* [m, Math.sqrt(v)]
14491449
* end
14501450
* ```
14511451
*
1452-
* @return (mean, stddev)
1452+
* @return (mean, stdev)
14531453
*/
14541454
static VALUE
1455-
ary_mean_stddev(int argc, VALUE* argv, VALUE ary)
1455+
ary_mean_stdev(int argc, VALUE* argv, VALUE ary)
14561456
{
14571457
VALUE opts, mean, variance;
14581458
size_t ddof = 1;
@@ -1462,12 +1462,12 @@ ary_mean_stddev(int argc, VALUE* argv, VALUE ary)
14621462
ddof = 0;
14631463

14641464
ary_mean_variance(ary, &mean, &variance, ddof);
1465-
VALUE stddev = sqrt_value(variance);
1466-
return rb_assoc_new(mean, stddev);
1465+
VALUE stdev = sqrt_value(variance);
1466+
return rb_assoc_new(mean, stdev);
14671467
}
14681468

14691469
/* call-seq:
1470-
* ary.stddev(population: false)
1470+
* ary.stdev(population: false)
14711471
*
14721472
* Calculate a standard deviation of the values in `ary`.
14731473
*
@@ -1480,11 +1480,11 @@ ary_mean_stddev(int argc, VALUE* argv, VALUE ary)
14801480
* @return [Number] A standard deviation value
14811481
*/
14821482
static VALUE
1483-
ary_stddev(int argc, VALUE* argv, VALUE ary)
1483+
ary_stdev(int argc, VALUE* argv, VALUE ary)
14841484
{
14851485
VALUE variance = ary_variance(argc, argv, ary);
1486-
VALUE stddev = sqrt_value(variance);
1487-
return stddev;
1486+
VALUE stdev = sqrt_value(variance);
1487+
return stdev;
14881488
}
14891489

14901490
void
@@ -1497,17 +1497,17 @@ Init_extension(void)
14971497
rb_define_method(rb_mEnumerable, "mean_variance", enum_mean_variance_m, -1);
14981498
rb_define_method(rb_mEnumerable, "mean", enum_mean, 0);
14991499
rb_define_method(rb_mEnumerable, "variance", enum_variance, -1);
1500-
rb_define_method(rb_mEnumerable, "mean_stddev", enum_mean_stddev, -1);
1501-
rb_define_method(rb_mEnumerable, "stddev", enum_stddev, -1);
1500+
rb_define_method(rb_mEnumerable, "mean_stdev", enum_mean_stdev, -1);
1501+
rb_define_method(rb_mEnumerable, "stdev", enum_stdev, -1);
15021502

15031503
#ifndef HAVE_ARRAY_SUM
15041504
rb_define_method(rb_cArray, "sum", ary_sum, -1);
15051505
#endif
15061506
rb_define_method(rb_cArray, "mean_variance", ary_mean_variance_m, -1);
15071507
rb_define_method(rb_cArray, "mean", ary_mean, 0);
15081508
rb_define_method(rb_cArray, "variance", ary_variance, -1);
1509-
rb_define_method(rb_cArray, "mean_stddev", ary_mean_stddev, -1);
1510-
rb_define_method(rb_cArray, "stddev", ary_stddev, -1);
1509+
rb_define_method(rb_cArray, "mean_stdev", ary_mean_stdev, -1);
1510+
rb_define_method(rb_cArray, "stdev", ary_stdev, -1);
15111511

15121512
half_in_rational = nurat_s_new_internal(rb_cRational, INT2FIX(1), INT2FIX(2));
15131513
rb_gc_register_mark_object(half_in_rational);

spec/array_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@
386386
end
387387
end
388388

389-
describe '#mean_stddev' do
389+
describe '#mean_stdev' do
390390
let(:ary) { [] }
391391
let(:block) { nil }
392392

393-
subject(:mean_stddev) { ary.mean_stddev(&block) }
393+
subject(:mean_stdev) { ary.mean_stdev(&block) }
394394

395395
with_array [] do
396396
specify do
@@ -401,7 +401,7 @@
401401
context 'with a conversion block' do
402402
it 'does not call the block' do
403403
expect { |b|
404-
ary.mean_stddev(&b)
404+
ary.mean_stdev(&b)
405405
}.not_to yield_control
406406
end
407407
end
@@ -423,23 +423,23 @@
423423

424424
with_array [3.0, 5.0] do
425425
context 'with population: nil' do
426-
subject(:mean_stddev) { ary.mean_stddev(population: nil, &block) }
426+
subject(:mean_stdev) { ary.mean_stdev(population: nil, &block) }
427427
specify do
428428
expect(subject[0]).to eq(4.0)
429429
expect(subject[1]).to eq(Math.sqrt(2.0))
430430
end
431431
end
432432

433433
context 'with population: false' do
434-
subject(:mean_stddev) { ary.mean_stddev(population: false, &block) }
434+
subject(:mean_stdev) { ary.mean_stdev(population: false, &block) }
435435
specify do
436436
expect(subject[0]).to eq(4.0)
437437
expect(subject[1]).to eq(Math.sqrt(2.0))
438438
end
439439
end
440440

441441
context 'with population: true' do
442-
subject(:mean_stddev) { ary.mean_stddev(population: true, &block) }
442+
subject(:mean_stdev) { ary.mean_stdev(population: true, &block) }
443443
specify do
444444
expect(subject[0]).to eq(4.0)
445445
expect(subject[1]).to eq(1.0)
@@ -481,11 +481,11 @@
481481
end
482482
end
483483

484-
describe '#stddev' do
484+
describe '#stdev' do
485485
let(:ary) { [] }
486486
let(:block) { nil }
487487

488-
subject(:stddev) { ary.stddev(&block) }
488+
subject(:stdev) { ary.stdev(&block) }
489489

490490
with_array [] do
491491
it_is_float_nan
@@ -495,7 +495,7 @@
495495

496496
it 'does not call the block' do
497497
expect { |b|
498-
ary.stddev(&b)
498+
ary.stdev(&b)
499499
}.not_to yield_control
500500
end
501501
end
@@ -517,17 +517,17 @@
517517
it_is_float_equal(Math.sqrt(2.0))
518518

519519
context 'with population: nil' do
520-
subject(:stddev) { ary.stddev(population: nil, &block) }
520+
subject(:stdev) { ary.stdev(population: nil, &block) }
521521
it_is_float_equal(Math.sqrt(2.0))
522522
end
523523

524524
context 'with population: false' do
525-
subject(:stddev) { ary.stddev(population: false, &block) }
525+
subject(:stdev) { ary.stdev(population: false, &block) }
526526
it_is_float_equal(Math.sqrt(2.0))
527527
end
528528

529529
context 'with population: true' do
530-
subject(:stddev) { ary.stddev(population: true, &block) }
530+
subject(:stdev) { ary.stdev(population: true, &block) }
531531
it_is_float_equal(1.0)
532532
end
533533
end

spec/enum_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@
381381
end
382382
end
383383

384-
describe '#stddev' do
385-
subject(:stddev) { enum.stddev(&block) }
384+
describe '#stdev' do
385+
subject(:stdev) { enum.stdev(&block) }
386386
let(:enum) { [].to_enum }
387387
let(:block) { nil }
388388

@@ -394,7 +394,7 @@
394394

395395
it 'does not call the block' do
396396
expect { |b|
397-
enum.stddev(&b)
397+
enum.stdev(&b)
398398
}.not_to yield_control
399399
end
400400
end
@@ -412,17 +412,17 @@
412412
it_is_float_equal(Math.sqrt(2.0))
413413

414414
context 'with population: nil' do
415-
subject(:stddev) { enum.stddev(population: nil, &block) }
415+
subject(:stdev) { enum.stdev(population: nil, &block) }
416416
it_is_float_equal(Math.sqrt(2.0))
417417
end
418418

419419
context 'with population: false' do
420-
subject(:stddev) { enum.stddev(population: false, &block) }
420+
subject(:stdev) { enum.stdev(population: false, &block) }
421421
it_is_float_equal(Math.sqrt(2.0))
422422
end
423423

424424
context 'with population: true' do
425-
subject(:stddev) { enum.stddev(population: true, &block) }
425+
subject(:stdev) { enum.stdev(population: true, &block) }
426426
it_is_float_equal(1.0)
427427
end
428428
end
@@ -471,8 +471,8 @@
471471
end
472472
end
473473

474-
describe '#mean_stddev' do
475-
subject(:mean_stddev) { enum.mean_stddev(&block) }
474+
describe '#mean_stdev' do
475+
subject(:mean_stdev) { enum.mean_stdev(&block) }
476476
let(:enum) { [].each }
477477
let(:block) { nil }
478478

@@ -486,7 +486,7 @@
486486
context 'with a conversion block' do
487487
it 'does not call the block' do
488488
expect { |b|
489-
enum.mean_stddev(&b)
489+
enum.mean_stdev(&b)
490490
}.not_to yield_control
491491
end
492492
end
@@ -508,23 +508,23 @@
508508

509509
with_enum [3.0, 5.0] do
510510
context 'with population: nil' do
511-
subject(:mean_stddev) { enum.mean_stddev(population: nil, &block) }
511+
subject(:mean_stdev) { enum.mean_stdev(population: nil, &block) }
512512
specify do
513513
expect(subject[0]).to eq(4.0)
514514
expect(subject[1]).to eq(Math.sqrt(2.0))
515515
end
516516
end
517517

518518
context 'with population: false' do
519-
subject(:mean_stddev) { enum.mean_stddev(population: false, &block) }
519+
subject(:mean_stdev) { enum.mean_stdev(population: false, &block) }
520520
specify do
521521
expect(subject[0]).to eq(4.0)
522522
expect(subject[1]).to eq(Math.sqrt(2.0))
523523
end
524524
end
525525

526526
context 'with population: true' do
527-
subject(:mean_stddev) { enum.mean_stddev(population: true, &block) }
527+
subject(:mean_stdev) { enum.mean_stdev(population: true, &block) }
528528
specify do
529529
expect(subject[0]).to eq(4.0)
530530
expect(subject[1]).to eq(1.0)

0 commit comments

Comments
 (0)