timesteps 0.9.5 → 1.0.0

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.
@@ -133,17 +133,6 @@ describe "Fixed360Day.parse_timestamp" do
133
133
 
134
134
  end
135
135
 
136
- example "with bc option" do
137
-
138
- d1 = DateTime::Fixed360Day.new(0, 1, 1, 0, 0, 0, 0)
139
- d2 = DateTime.parse_timestamp('BC 0001-1-1 00:00:00', calendar: "360_day")
140
- d3 = DateTime.parse_timestamp('-0001-1-1 00:00:00', calendar: "360_day", bc: true)
141
-
142
- is_asserted_by { d2 == d1 }
143
- is_asserted_by { d3 == d1 }
144
-
145
- end
146
-
147
136
  example '2000-12-31 24:00:00' do
148
137
 
149
138
  d1 = DateTime::Fixed360Day.new(2001, 1, 1, 0, 0, 0, 0)
@@ -312,8 +301,8 @@ describe "Fixed360Day#difference_in_years" do
312
301
  d3 = DateTime::Fixed360Day.new(2002, 3, 5, 9, 35, 11.5, 9.quo(24))
313
302
  d4 = DateTime::Fixed360Day.new(2002, 3, 5, 9, 35, 12.5, 9.quo(24))
314
303
 
315
- is_asserted_by { d2.difference_in_years(d1) == 0 }
316
- is_asserted_by { d3.difference_in_years(d1) == 0 }
304
+ is_asserted_by { d2.difference_in_years(d1) == 1.quo(2) }
305
+ is_asserted_by { d3.difference_in_years(d1) == 1.quo(2) }
317
306
  is_asserted_by { d4.difference_in_years(d1) == 1 }
318
307
 
319
308
  end
@@ -330,8 +319,8 @@ describe "Fixed360Day#difference_in_months" do
330
319
  d4 = DateTime::Fixed360Day.new(2001, 4, 5, 9, 35, 12.5, 9.quo(24))
331
320
  d5 = DateTime::Fixed360Day.new(2002, 3, 5, 9, 35, 12.5, 9.quo(24))
332
321
 
333
- is_asserted_by { d2.difference_in_months(d1) == 0 }
334
- is_asserted_by { d3.difference_in_months(d1) == 0 }
322
+ is_asserted_by { d2.difference_in_months(d1) == 1.quo(2) }
323
+ is_asserted_by { d3.difference_in_months(d1) == 1.quo(2) }
335
324
  is_asserted_by { d4.difference_in_months(d1) == 1 }
336
325
  is_asserted_by { d5.difference_in_months(d1) == 12 }
337
326
 
data/spec/noleap_spec.rb CHANGED
@@ -121,17 +121,6 @@ describe "NoLeap.parse_timestamp" do
121
121
 
122
122
  end
123
123
 
124
- example "with bc option" do
125
-
126
- d1 = DateTime::NoLeap.new(0, 1, 1, 0, 0, 0, 0)
127
- d2 = DateTime.parse_timestamp('BC 0001-1-1 00:00:00', calendar: "noleap")
128
- d3 = DateTime.parse_timestamp('-0001-1-1 00:00:00', calendar: "noleap", bc: true)
129
-
130
- is_asserted_by { d2 == d1 }
131
- is_asserted_by { d3 == d1 }
132
-
133
- end
134
-
135
124
  example '2000-12-31 24:00:00' do
136
125
 
137
126
  d1 = DateTime::NoLeap.new(2001, 1, 1, 0, 0, 0, 0)
@@ -300,8 +289,8 @@ describe "NoLeap#difference_in_years" do
300
289
  d3 = DateTime::NoLeap.new(2002, 3, 5, 9, 35, 11.5, 9.quo(24))
301
290
  d4 = DateTime::NoLeap.new(2002, 3, 5, 9, 35, 12.5, 9.quo(24))
302
291
 
303
- is_asserted_by { d2.difference_in_years(d1) == 0 }
304
- is_asserted_by { d3.difference_in_years(d1) == 0 }
292
+ is_asserted_by { d2.difference_in_years(d1) == 1.quo(2) }
293
+ is_asserted_by { d3.difference_in_years(d1) == 1.quo(2) }
305
294
  is_asserted_by { d4.difference_in_years(d1) == 1 }
306
295
 
307
296
  end
@@ -231,7 +231,7 @@ describe "TimeStep#time_at" do
231
231
  is_asserted_by { ts.time_at(-366) == ts.origin.prev_month(366) }
232
232
 
233
233
  # months timestep don't permit fractional index
234
- expect { ts.time_at(1.5) }.to raise_error(RuntimeError)
234
+ expect { ts.time_at(1.5) }.to raise_error(ArgumentError)
235
235
 
236
236
  end
237
237
 
@@ -250,7 +250,7 @@ describe "TimeStep#time_at" do
250
250
  is_asserted_by { ts.time_at(-366) == ts.origin.prev_year(366) }
251
251
 
252
252
  # years timestep don't permit fractional index
253
- expect { ts.time_at(1.5) }.to raise_error(RuntimeError)
253
+ expect { ts.time_at(1.5) }.to raise_error(ArgumentError)
254
254
 
255
255
  end
256
256
 
@@ -319,10 +319,10 @@ describe "TimeStep#index_at" do
319
319
  is_asserted_by { ts.index_at( ts.origin.next_year(100) ) == 100 }
320
320
  is_asserted_by { ts.index_at( ts.origin.prev_year(1) ) == -1 }
321
321
  is_asserted_by { ts.index_at( ts.origin.prev_year(100) ) == -100 }
322
- is_asserted_by { ts.index_at( ts.origin.next_year(1) - 1 ) == 0 }
323
- is_asserted_by { ts.index_at( ts.origin.next_year(100) - 1 ) == 99 }
324
- is_asserted_by { ts.index_at( ts.origin.prev_year(1) + 1 ) == 0 }
325
- is_asserted_by { ts.index_at( ts.origin.prev_year(100) + 1 ) == -99 }
322
+ is_asserted_by { ts.index_at( ts.origin.next_year(1) - 1 ).floor == 0 }
323
+ is_asserted_by { ts.index_at( ts.origin.next_year(100) - 1 ).floor == 99 }
324
+ is_asserted_by { ts.index_at( ts.origin.prev_year(1) + 1 ).floor == -1 }
325
+ is_asserted_by { ts.index_at( ts.origin.prev_year(100) + 1 ).floor == -100 }
326
326
 
327
327
  end
328
328
 
@@ -339,7 +339,7 @@ describe "TimeStep#index_at" do
339
339
 
340
340
  end
341
341
 
342
- describe "TimeStep#days_at" do
342
+ describe "TimeStep#duration_at" do
343
343
 
344
344
  example 'seconds' do
345
345
 
@@ -347,25 +347,25 @@ describe "TimeStep#days_at" do
347
347
 
348
348
  ts = TimeStep.new("1 seconds since 2001-02-03 04:05:06 +07:00", calendar: calendar)
349
349
 
350
- is_asserted_by { ts.days_at( 1 ) == 1.quo(86400) }
351
- is_asserted_by { ts.days_at( 100 ) == 100.quo(86400) }
352
- is_asserted_by { ts.days_at( 0.5 ) == 0.5.to_r.quo(86400) }
353
- is_asserted_by { ts.days_at( -0.5 ) == -0.5.to_r.quo(86400) }
350
+ is_asserted_by { ts.duration_at( 1 ) == 1.quo(86400) }
351
+ is_asserted_by { ts.duration_at( 100 ) == 100.quo(86400) }
352
+ is_asserted_by { ts.duration_at( 0.5 ) == 0.5.to_r.quo(86400) }
353
+ is_asserted_by { ts.duration_at( -0.5 ) == -0.5.to_r.quo(86400) }
354
354
 
355
355
  end
356
356
 
357
357
  end
358
358
 
359
- example 'days' do
359
+ example 'duration' do
360
360
 
361
361
  CALENDAR_NAMES.each do |calendar|
362
362
 
363
363
  ts = TimeStep.new("1 days since 2001-02-03 04:05:06 +07:00", calendar: calendar)
364
364
 
365
- is_asserted_by { ts.days_at( 1 ) == 1 }
366
- is_asserted_by { ts.days_at( 100 ) == 100 }
367
- is_asserted_by { ts.days_at( 0.5 ) == 0.5 }
368
- is_asserted_by { ts.days_at( -0.5 ) == -0.5 }
365
+ is_asserted_by { ts.duration_at( 1 ) == 1 }
366
+ is_asserted_by { ts.duration_at( 100 ) == 100 }
367
+ is_asserted_by { ts.duration_at( 0.5 ) == 0.5 }
368
+ is_asserted_by { ts.duration_at( -0.5 ) == -0.5 }
369
369
 
370
370
  end
371
371
 
@@ -377,10 +377,10 @@ describe "TimeStep#days_at" do
377
377
 
378
378
  ts = TimeStep.new("1 months since 2001-02-03 04:05:06 +07:00", calendar: calendar)
379
379
 
380
- is_asserted_by { ts.days_at( 1 ) == ts.origin.next_month - ts.origin }
381
- is_asserted_by { ts.days_at( 100 ) == ts.origin.next_month(100) - ts.origin }
382
- is_asserted_by { ts.days_at( -1 ) == ts.origin.prev_month - ts.origin }
383
- is_asserted_by { ts.days_at( -100 ) == ts.origin.prev_month(100) - ts.origin }
380
+ is_asserted_by { ts.duration_at( 1 ) == ts.origin.next_month - ts.origin }
381
+ is_asserted_by { ts.duration_at( 100 ) == ts.origin.next_month(100) - ts.origin }
382
+ is_asserted_by { ts.duration_at( -1 ) == ts.origin.prev_month - ts.origin }
383
+ is_asserted_by { ts.duration_at( -100 ) == ts.origin.prev_month(100) - ts.origin }
384
384
 
385
385
  end
386
386
 
@@ -392,10 +392,10 @@ describe "TimeStep#days_at" do
392
392
 
393
393
  ts = TimeStep.new("1 years since 2001-02-03 04:05:06 +07:00", calendar: calendar)
394
394
 
395
- is_asserted_by { ts.days_at( 1 ) == ts.origin.next_year - ts.origin }
396
- is_asserted_by { ts.days_at( 100 ) == ts.origin.next_year(100) - ts.origin }
397
- is_asserted_by { ts.days_at( -1 ) == ts.origin.prev_year - ts.origin }
398
- is_asserted_by { ts.days_at( -100 ) == ts.origin.prev_year(100) - ts.origin }
395
+ is_asserted_by { ts.duration_at( 1 ) == ts.origin.next_year - ts.origin }
396
+ is_asserted_by { ts.duration_at( 100 ) == ts.origin.next_year(100) - ts.origin }
397
+ is_asserted_by { ts.duration_at( -1 ) == ts.origin.prev_year - ts.origin }
398
+ is_asserted_by { ts.duration_at( -100 ) == ts.origin.prev_year(100) - ts.origin }
399
399
 
400
400
  end
401
401
 
@@ -436,26 +436,3 @@ describe "TimeStep#new_origin" do
436
436
 
437
437
  end
438
438
 
439
- describe "TimeStep#limit" do
440
-
441
- example do
442
-
443
- CALENDAR_NAMES.each do |calendar|
444
-
445
- ts = TimeStep.new("1 hours since 2001-02-03 04:05:06 +07:00", calendar: calendar, count: 31)
446
- is_asserted_by { ts.limit == ts.time_at(30) }
447
-
448
- ts = TimeStep.new("1 hours since 2001-02-03 04:05:06 +07:00", calendar: calendar)
449
- ts.count = 31
450
- is_asserted_by { ts.limit == ts.time_at(30) }
451
-
452
- ts = TimeStep.new("1 hours since 2001-02-03 04:05:06 +07:00", calendar: calendar)
453
- ts.limit = ts.time_at(30)
454
- is_asserted_by { ts.count == 31 }
455
-
456
- end
457
-
458
- end
459
-
460
- end
461
-
@@ -63,7 +63,7 @@ describe "TimeStep::Pair#forward" do
63
63
  is_asserted_by { pair.forward(1) == 4 }
64
64
  is_asserted_by { pair.forward(10) == 31 }
65
65
 
66
- expect { pair.forward(1.5) }.to raise_error(RuntimeError)
66
+ expect { pair.forward(1.5) }.to raise_error(ArgumentError)
67
67
  end
68
68
 
69
69
  example "different years" do
@@ -77,7 +77,7 @@ describe "TimeStep::Pair#forward" do
77
77
  is_asserted_by { pair.forward(1) == 4 }
78
78
  is_asserted_by { pair.forward(10) == 31 }
79
79
 
80
- expect { pair.forward(1.5) }.to raise_error(RuntimeError)
80
+ expect { pair.forward(1.5) }.to raise_error(ArgumentError)
81
81
 
82
82
  end
83
83
 
data/timesteps.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  Gem::Specification::new do |s|
3
- version = "0.9.5"
3
+ version = "1.0.0"
4
4
 
5
- files = Dir.glob("**/*") - [
5
+ files = Dir.glob("**/*") + [".yardopts"] - [
6
6
  Dir.glob("timesteps-*.gem"),
7
7
  Dir.glob("doc/**/*"),
8
8
  Dir.glob("examples/**/*"),
@@ -20,7 +20,7 @@ Gem::Specification::new do |s|
20
20
  describe the time axis when dealing with time series of observational data and climate data.
21
21
  HERE
22
22
  s.version = version
23
- s.licenses = ['MIT']
23
+ s.license = 'MIT'
24
24
  s.author = "Hiroki Motoyoshi"
25
25
  s.email = ""
26
26
  s.homepage = 'https://github.com/himotoyoshi/timesteps'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timesteps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-08 00:00:00.000000000 Z
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A library for time conversion and intercomparison of multiple time
14
14
  series data \n in the case of handling time series data of the type that specifies
@@ -22,23 +22,30 @@ executables: []
22
22
  extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
- - LICENSES
25
+ - ".yardopts"
26
+ - LICENSE
27
+ - NEWS.md
26
28
  - Note.ja.md
27
29
  - README.md
28
30
  - Rakefile
29
31
  - lib/timesteps.rb
30
- - lib/timesteps/calendar.rb
31
32
  - lib/timesteps/datetime_360day.rb
32
33
  - lib/timesteps/datetime_allleap.rb
33
34
  - lib/timesteps/datetime_noleap.rb
35
+ - lib/timesteps/datetime_parse_timestamp.rb
36
+ - lib/timesteps/datetime_timestep.rb
34
37
  - lib/timesteps/datetimelike.rb
35
- - lib/timesteps/format.rb
38
+ - lib/timesteps/datetimelike_format.rb
36
39
  - lib/timesteps/grads.rb
37
- - lib/timesteps/parse_timestamp.rb
40
+ - lib/timesteps/time.rb
41
+ - lib/timesteps/timeperiod.rb
38
42
  - lib/timesteps/timestep.rb
43
+ - lib/timesteps/timestep_calendar.rb
39
44
  - lib/timesteps/timestep_converter.rb
40
45
  - lib/timesteps/timestep_datetime_ext.rb
41
46
  - lib/timesteps/timestep_pair.rb
47
+ - lib/timesteps/timestep_query.rb
48
+ - lib/timesteps/timestep_range.rb
42
49
  - spec/allleap_spec.rb
43
50
  - spec/fixed360day_spec.rb
44
51
  - spec/noleap_spec.rb
@@ -64,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
71
  - !ruby/object:Gem::Version
65
72
  version: '0'
66
73
  requirements: []
67
- rubygems_version: 3.0.3
74
+ rubygems_version: 3.1.2
68
75
  signing_key:
69
76
  specification_version: 4
70
77
  summary: A library for handling discrete time series in constant increments