mspire 0.10.0 → 0.10.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
  SHA1:
3
- metadata.gz: 10f9f35036ad4f2a25b69644aa4157281bc18ccb
4
- data.tar.gz: 3d5001ce1de7d3d5da82c5de7b3440c93d34abbb
3
+ metadata.gz: c92ec4a23bf1ecef8abc24269b4e680c8a7ed8bd
4
+ data.tar.gz: 1016a66f7c99acf348ae1a439c77fd54e91431f6
5
5
  SHA512:
6
- metadata.gz: aa2b1352be5a165feeca924d1690fde4e43d980df05aee0dc9a30768644a6a7e6cac645171d93ff83cebddd340660c13fec17d6e27e9e8e31a134d35bfe1fed4
7
- data.tar.gz: 8e6cc4877db87cbb408c53966570277ebb14eccbf308c8a7e9eadbe793c430e7f25cabd8be492d4f7cef93d0860955265cb48af3a4127fa86a7de5e7b83e99d2
6
+ metadata.gz: a09382c44d33e3cb5d6f3d307c8306a06af85851645f3d4ee80799b85ecbd41e87b53b8b29ee758909050776356d88eda131b77f169493b299a42af0954486b5
7
+ data.tar.gz: b3161fcf60c22a25b2c736612b7d9798c95185a45b9de97d181c791b6311d58fc73a927540385c908b26a394ca0f5dbe550b646e331da8f0d1f924054a216cb4
data/lib/mspire/bin.rb CHANGED
@@ -38,25 +38,27 @@ module Mspire
38
38
  #
39
39
  #
40
40
  def self.bin(bins, objects, *data_capture_obj, &block)
41
- obj_e = objects.each ; obj = obj_e.next
42
-
43
41
  data_capture = data_capture_obj.first || bins
44
42
 
45
- bin_i = 0 # the bin index
46
- cbin = bins[bin_i] # the current bin
47
- done = false
48
- until done
49
- value = (block.nil? ? obj : block.call(obj))
50
- if cbin.begin <= value
51
- until cbin === value && data_capture[bin_i] << obj
52
- bin_i += 1
53
- cbin=bins[bin_i] || (done=true && break)
54
- end
55
- obj=obj_e.next rescue done=true
56
- else
57
- while cbin.begin > value && !done
58
- obj=obj_e.next rescue done=true && break
59
- value = (block.nil? ? obj : block.call(obj))
43
+ if objects.size > 0
44
+ obj_e = objects.each ; obj = obj_e.next
45
+
46
+ bin_i = 0 # the bin index
47
+ cbin = bins[bin_i] # the current bin
48
+ done = false
49
+ until done
50
+ value = (block.nil? ? obj : block.call(obj))
51
+ if cbin.begin <= value
52
+ until cbin === value && data_capture[bin_i] << obj
53
+ bin_i += 1
54
+ cbin=bins[bin_i] || (done=true && break)
55
+ end
56
+ obj=obj_e.next rescue done=true
57
+ else
58
+ while cbin.begin > value && !done
59
+ obj=obj_e.next rescue done=true && break
60
+ value = (block.nil? ? obj : block.call(obj))
61
+ end
60
62
  end
61
63
  end
62
64
  end
@@ -7,11 +7,11 @@ module Mspire
7
7
  class Peaklist < Array
8
8
 
9
9
  def lo_x
10
- self.first[0]
10
+ self.first[0] if size > 0
11
11
  end
12
12
 
13
13
  def hi_x
14
- self.last[0]
14
+ self.last[0] if size > 0
15
15
  end
16
16
 
17
17
  DEFAULT_MERGE = {
@@ -77,8 +77,10 @@ module Mspire
77
77
  first_peaklist = peaklists.first
78
78
  min = first_peaklist.first.x; max = first_peaklist.last.x
79
79
  peaklists.each do |peaklist|
80
- min = peaklist.lo_x if peaklist.lo_x < min
81
- max = peaklist.hi_x if peaklist.hi_x > max
80
+ if peaklist.size > 0
81
+ min = peaklist.lo_x if peaklist.lo_x < min
82
+ max = peaklist.hi_x if peaklist.hi_x > max
83
+ end
82
84
  end
83
85
  [min, max]
84
86
  end
@@ -355,6 +357,15 @@ module Mspire
355
357
  no_lm_pklsts
356
358
  end
357
359
  end # def split
360
+
361
+ # returns an Mspire::Spectrum object
362
+ def to_spectrum
363
+ xs = [] ; ys = []
364
+ each do |peak|
365
+ xs << peak.x ; ys << peak.y
366
+ end
367
+ Mspire::Spectrum.new([xs, ys])
368
+ end
358
369
  end
359
370
  end
360
371
 
@@ -83,11 +83,11 @@ module Mspire
83
83
  pl = Peaklist.new
84
84
  if peak_id
85
85
  peaks.each_with_index do |peak,i|
86
- pl[i] = Mspire::Peak.new( peak )
86
+ pl[i] = Mspire::TaggedPeak.new( peak, peak_id )
87
87
  end
88
88
  else
89
89
  peaks.each_with_index do |peak,i|
90
- pl[i] = Mspire::TaggedPeak.new( peak, peak_id )
90
+ pl[i] = Mspire::Peak.new( peak )
91
91
  end
92
92
  end
93
93
  pl
@@ -1,3 +1,3 @@
1
1
  module Mspire
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John T. Prince
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-11 00:00:00.000000000 Z
12
+ date: 2013-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -547,4 +547,3 @@ test_files:
547
547
  - spec/testfiles/mspire/quant/unlog_transform.rb
548
548
  - spec/testfiles/plms1/output.key
549
549
  - spec/testfiles/processed_binary.tmp.ibd
550
- has_rdoc: