text-data-tools 1.1.3 → 1.1.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.1.4
@@ -158,6 +158,9 @@ module Column
158
158
  # appropriate options,
159
159
  # then call methods from TextDataTools omitting the appropriate arguments.
160
160
  class DataFile < DataFileBase
161
+ def inspect
162
+ "#{self.class}.new(#{@filename.inspect}, #{@has_header_line.inspect}, #{@match.inspect}, #{@header_match.inspect})"
163
+ end
161
164
  def initialize(filename, has_header_line = false, match = /\S+/, header_match = /\S+/)
162
165
  @filename = filename
163
166
  @match = match
@@ -232,6 +235,9 @@ module Named
232
235
  @sep = sep
233
236
  self
234
237
  end
238
+ def inspect
239
+ "#{self.class}.new(#{@filename.inspect}, #{@sep.inspect})"
240
+ end
235
241
  def get_variable_value(name)
236
242
  TextDataTools::Named.get_variable_value(@filename, name, @sep)
237
243
  end
@@ -0,0 +1,55 @@
1
+ # 1: time 2: radius 3: i+ pflx 4: e- pflx 5: Qi (GB) 5: Qe (GB) 7: Qi (MW/m^2) 8: Qe (MW/m^2)
2
+ 0.0000E+00 0.1000E+00 -0.3110E-01 -0.3110E-01 0.1975E-02 0.0000E+00 0.3415E-02 0.0000E+00
3
+ 0.0000E+00 0.2000E+00 -0.1992E-01 -0.1992E-01 0.1440E-02 0.0000E+00 0.2295E-02 0.0000E+00
4
+ 0.0000E+00 0.3000E+00 -0.1543E-01 -0.1543E-01 0.1254E-02 0.0000E+00 0.1795E-02 0.0000E+00
5
+ 0.0000E+00 0.4000E+00 -0.3949E-02 -0.3949E-02 0.2595E-02 0.0000E+00 0.3044E-02 0.0000E+00
6
+ 0.0000E+00 0.5000E+00 0.2528E-02 0.2528E-02 0.2510E+01 0.2852E+00 0.2225E+01 0.2439E+00
7
+ 0.0000E+00 0.5000E+00 0.1258E-01 0.1258E-01 0.3515E+01 0.4851E+00 0.1981E+01 0.2734E+00
8
+ 0.0000E+00 0.7000E+00 0.4505E-01 0.4505E-01 0.4351E+01 0.1301E+01 0.1505E+01 0.4491E+00
9
+ 0.0000E+00 0.8000E+00 0.8113E-01 0.8113E-01 0.2585E+01 0.1413E+01 0.5132E+00 0.2804E+00
10
+
11
+ 0.0000E+00 0.1000E+00 -0.3110E-01 -0.3110E-01 0.2173E-02 0.0000E+00 0.3415E-02 0.0000E+00
12
+ 0.0000E+00 0.2000E+00 -0.1992E-01 -0.1992E-01 0.1585E-02 0.0000E+00 0.2295E-02 0.0000E+00
13
+ 0.0000E+00 0.3000E+00 -0.1543E-01 -0.1543E-01 0.1391E-02 0.0000E+00 0.1795E-02 0.0000E+00
14
+ 0.0000E+00 0.4000E+00 -0.3949E-02 -0.3949E-02 0.2855E-02 0.0000E+00 0.3044E-02 0.0000E+00
15
+ 0.0000E+00 0.5000E+00 0.2528E-02 0.2528E-02 0.3325E+01 0.3315E+00 0.2225E+01 0.2439E+00
16
+ 0.0000E+00 0.5000E+00 0.1258E-01 0.1258E-01 0.4419E+01 0.5545E+00 0.1981E+01 0.2734E+00
17
+ 0.0000E+00 0.7000E+00 0.4505E-01 0.4505E-01 0.5481E+01 0.1487E+01 0.1505E+01 0.4491E+00
18
+ 0.0000E+00 0.8000E+00 0.8113E-01 0.8113E-01 0.4241E+01 0.2113E+01 0.5132E+00 0.2804E+00
19
+
20
+ 0.0000E+00 0.1000E+00 -0.3045E-01 -0.3045E-01 0.1975E-02 0.0000E+00 0.3415E-02 0.0000E+00
21
+ 0.0000E+00 0.2000E+00 -0.1893E-01 -0.1893E-01 0.1440E-02 0.0000E+00 0.2295E-02 0.0000E+00
22
+ 0.0000E+00 0.3000E+00 -0.1410E-01 -0.1410E-01 0.1254E-02 0.0000E+00 0.1795E-02 0.0000E+00
23
+ 0.0000E+00 0.4000E+00 -0.1418E-02 -0.1418E-02 0.2595E-02 0.0000E+00 0.3044E-02 0.0000E+00
24
+ 0.0000E+00 0.5000E+00 0.5932E-02 0.5932E-02 0.2510E+01 0.3148E+00 0.2225E+01 0.2439E+00
25
+ 0.0000E+00 0.5000E+00 0.1593E-01 0.1593E-01 0.3515E+01 0.5335E+00 0.1981E+01 0.2734E+00
26
+ 0.0000E+00 0.7000E+00 0.5107E-01 0.5107E-01 0.4351E+01 0.1431E+01 0.1505E+01 0.4491E+00
27
+ 0.0000E+00 0.8000E+00 0.8842E-01 0.8842E-01 0.2585E+01 0.1554E+01 0.5132E+00 0.2804E+00
28
+
29
+
30
+ 0.3125E-02 0.1000E+00 -0.3110E-01 -0.3110E-01 0.1944E-02 0.0000E+00 0.3355E-02 0.0000E+00
31
+ 0.3125E-02 0.2000E+00 -0.1990E-01 -0.1990E-01 0.1445E-02 0.0000E+00 0.2307E-02 0.0000E+00
32
+ 0.3125E-02 0.3000E+00 -0.1547E-01 -0.1547E-01 0.1234E-02 0.0000E+00 0.1759E-02 0.0000E+00
33
+ 0.3125E-02 0.4000E+00 -0.2783E-02 -0.2783E-02 0.8015E+00 0.8734E-01 0.9122E+00 0.9941E-01
34
+ 0.3125E-02 0.5000E+00 0.2105E-02 0.2105E-02 0.1512E+01 0.2001E+00 0.1308E+01 0.1524E+00
35
+ 0.3125E-02 0.5000E+00 0.1343E-01 0.1343E-01 0.2903E+01 0.4412E+00 0.1524E+01 0.2458E+00
36
+ 0.3125E-02 0.7000E+00 0.4473E-01 0.4473E-01 0.3519E+01 0.1112E+01 0.1277E+01 0.3923E+00
37
+ 0.3125E-02 0.8000E+00 0.8077E-01 0.8077E-01 0.3540E+01 0.1854E+01 0.7413E+00 0.3797E+00
38
+
39
+ 0.3125E-02 0.1000E+00 -0.3110E-01 -0.3110E-01 0.2138E-02 0.0000E+00 0.3355E-02 0.0000E+00
40
+ 0.3125E-02 0.2000E+00 -0.1990E-01 -0.1990E-01 0.1590E-02 0.0000E+00 0.2307E-02 0.0000E+00
41
+ 0.3125E-02 0.3000E+00 -0.1547E-01 -0.1547E-01 0.1357E-02 0.0000E+00 0.1759E-02 0.0000E+00
42
+ 0.3125E-02 0.4000E+00 -0.2783E-02 -0.2783E-02 0.1508E+01 0.1595E+00 0.9122E+00 0.9941E-01
43
+ 0.3125E-02 0.5000E+00 0.2105E-02 0.2105E-02 0.2438E+01 0.2754E+00 0.1308E+01 0.1524E+00
44
+ 0.3125E-02 0.5000E+00 0.1343E-01 0.1343E-01 0.3725E+01 0.5150E+00 0.1524E+01 0.2458E+00
45
+ 0.3125E-02 0.7000E+00 0.4473E-01 0.4473E-01 0.4540E+01 0.1295E+01 0.1277E+01 0.3923E+00
46
+ 0.3125E-02 0.8000E+00 0.8077E-01 0.8077E-01 0.4983E+01 0.2323E+01 0.7413E+00 0.3797E+00
47
+
48
+ 0.3125E-02 0.1000E+00 -0.3047E-01 -0.3047E-01 0.1944E-02 0.0000E+00 0.3355E-02 0.0000E+00
49
+ 0.3125E-02 0.2000E+00 -0.1891E-01 -0.1891E-01 0.1445E-02 0.0000E+00 0.2307E-02 0.0000E+00
50
+ 0.3125E-02 0.3000E+00 -0.1415E-01 -0.1415E-01 0.1234E-02 0.0000E+00 0.1759E-02 0.0000E+00
51
+ 0.3125E-02 0.4000E+00 -0.1352E-03 -0.1352E-03 0.8015E+00 0.9508E-01 0.9122E+00 0.9941E-01
52
+ 0.3125E-02 0.5000E+00 0.5357E-02 0.5357E-02 0.1512E+01 0.2201E+00 0.1308E+01 0.1524E+00
53
+ 0.3125E-02 0.5000E+00 0.1585E-01 0.1585E-01 0.2903E+01 0.4853E+00 0.1524E+01 0.2458E+00
54
+ 0.3125E-02 0.7000E+00 0.4951E-01 0.4951E-01 0.3519E+01 0.1223E+01 0.1277E+01 0.3923E+00
55
+ 0.3125E-02 0.8000E+00 0.8803E-01 0.8803E-01 0.3540E+01 0.2051E+01 0.7413E+00 0.3797E+00
@@ -23,6 +23,11 @@ class TestTextDataTools < Test::Unit::TestCase
23
23
  #assert_equal(array[9].to_f, 0.9753E+09)
24
24
 
25
25
  end
26
+ def test_2d_newlines
27
+ file = TextDataTools::Column::DataFile.new('test/test_dat_new_lines.dat', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
28
+ array = file.get_2d_array(/Qi.*GB/, /1.*time/)
29
+ assert_equal(24, array[0].size)
30
+ end
26
31
  def test_get_variable
27
32
  variable = TextDataTools::Named.get_variable_value('test/test_dat_2.dat', 'Q', ':')
28
33
  assert_equal(variable.to_f, 11.989644168449118)
@@ -36,5 +41,16 @@ class TestTextDataTools < Test::Unit::TestCase
36
41
  array = file.get_2d_array(/i\+ temp/, /1.*time/)
37
42
  assert_equal(array.size, 2)
38
43
  assert(file.exists?)
44
+ array = file.get_2d_array_float(/i\+ temp/, 0)
45
+ assert_equal(array[0].size, 9)
46
+ assert_equal(array[1][0], 0.9753E+09)
47
+ end
48
+ def test_inspect
49
+ file1 = TextDataTools::Named::DataFile.new('test/test_dat_2.dat', ':')
50
+ file2 = TextDataTools::Column::DataFile.new('test/test_dat.dat', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
51
+ file1a = eval(file1.inspect)
52
+ file2a = eval(file2.inspect)
53
+ assert_equal(file1.instance_variable_get(:@filename), file1a.instance_variable_get(:@filename))
54
+ assert_equal(file2.instance_variable_get(:@header_match), file2a.instance_variable_get(:@header_match))
39
55
  end
40
56
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "text-data-tools"
8
- s.version = "1.1.3"
8
+ s.version = "1.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
12
- s.date = "2013-06-17"
12
+ s.date = "2013-06-19"
13
13
  s.description = "A small set of tools for reading text based data files into arrays. Works ee.g. for simple columnar data with or without headings."
14
14
  s.email = "edmundhighcock@sourceforge.net"
15
15
  s.extra_rdoc_files = [
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "test/helper.rb",
29
29
  "test/test_dat.dat",
30
30
  "test/test_dat_2.dat",
31
+ "test/test_dat_new_lines.dat",
31
32
  "test/test_text-data-tools.rb",
32
33
  "text-data-tools.gemspec"
33
34
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text-data-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-17 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -95,6 +95,7 @@ files:
95
95
  - test/helper.rb
96
96
  - test/test_dat.dat
97
97
  - test/test_dat_2.dat
98
+ - test/test_dat_new_lines.dat
98
99
  - test/test_text-data-tools.rb
99
100
  - text-data-tools.gemspec
100
101
  - README.rdoc.orig
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
114
  version: '0'
114
115
  segments:
115
116
  - 0
116
- hash: 4040948979312739110
117
+ hash: 1069568259517318027
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  none: false
119
120
  requirements: