daru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a2952b88ba0b72a6d7ada74bd03b03b7690f774
4
+ data.tar.gz: fdace87c3406adda7f141aaab055fb1e40c66e0c
5
+ SHA512:
6
+ metadata.gz: be50d9aafa90638208605de2bd68c121df1ce72eebe463ed3ec06f548104b5f86f73ea572b7424e03fca518f21f3425dc05608ace18cd3d430111c61b526ce3a
7
+ data.tar.gz: 10c7243159bad7188f99095308035dc5064bea91d4ba966264f6d84a4b8dfac86c096f126df7c149da331770efdc3c0e8b2a54b48d6bd121ff046d0c9b5d740a
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in daru.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ daru (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ json (1.8.1)
11
+ nmatrix (0.1.0.rc5)
12
+ rdoc (~> 4.0, >= 4.0.1)
13
+ rdoc (4.1.2)
14
+ json (~> 1.4)
15
+ rspec (3.1.0)
16
+ rspec-core (~> 3.1.0)
17
+ rspec-expectations (~> 3.1.0)
18
+ rspec-mocks (~> 3.1.0)
19
+ rspec-core (3.1.5)
20
+ rspec-support (~> 3.1.0)
21
+ rspec-expectations (3.1.2)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.1.0)
24
+ rspec-mocks (3.1.2)
25
+ rspec-support (~> 3.1.0)
26
+ rspec-support (3.1.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler
33
+ daru!
34
+ nmatrix (~> 0.1.0.rc5)
35
+ rspec (~> 3.0)
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2014, Sameer Deshmukh
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ daru
2
+ ====
3
+
4
+ Data Analysis in RUby
data/daru.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+
4
+ require 'version.rb'
5
+
6
+ DESCRIPTION = <<MSG
7
+ Daru (Data Analysis in RUby) is a library for storage, analysis and manipulation
8
+ of data. It aims to be the preferred data storage library for all Ruby gems, promoting
9
+ interoperability and easy of use between various ruby packages.
10
+ MSG
11
+
12
+ Gem::Specification.new do |spec|
13
+ spec.name = 'daru'
14
+ spec.version = Daru::VERSION
15
+ spec.authors = ['Sameer Deshmukh']
16
+ spec.email = ['sameer.deshmukh93@gmail.com']
17
+ spec.summary = %q{Data Analysis in RUby}
18
+ spec.description = DESCRIPTION
19
+ spec.homepage = "http://github.com/v0dro/daru"
20
+ spec.license = 'BSD-2'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency 'bundler'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'nmatrix', '~> 0.1.0.rc5'
30
+ end
data/lib/daru.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'securerandom'
2
+ require 'matrix'
3
+
4
+ require 'daru/vector.rb'
5
+ require 'daru/dataframe.rb'
@@ -0,0 +1,7 @@
1
+ module Daru
2
+ class DataFrame
3
+ def initialize source, name=SecureRandom.uuid
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ module Daru
2
+ class Vector
3
+ include Enumerable
4
+
5
+ def each(&block)
6
+ @vector.each(&block)
7
+ end
8
+
9
+ attr_reader :name
10
+
11
+ attr_reader :size
12
+
13
+ def initialize source, name=SecureRandom.uuid
14
+ @name = source.is_a?(Hash) ? source.keys[0] : name
15
+
16
+ @vector =
17
+ if source.is_a? Hash
18
+ source.values[0].is_a?(Range) ? source.values[0].to_a : source.values[0]
19
+ elsif source.is_a? Range or source.is_a? Matrix
20
+ source.to_a.flatten
21
+ else
22
+ source
23
+ end
24
+
25
+ @size = @vector.size
26
+ end
27
+
28
+ def [](index)
29
+ @vector[index]
30
+ end
31
+ end
32
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Daru
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ # Tests if interpreter is JRuby
@@ -0,0 +1,19 @@
1
+ # Tests if interpreter is JRuby
2
+
3
+ # describe Daru::Vector do
4
+ # context ".initialize" do
5
+ # it "creates a vector object with an MDArray" do
6
+ # vector = Daru::Vector.new(MDArray.new([5], [1,2,3,4,5]), :uhura)
7
+
8
+ # expect(vector[1]) .to eq(2)
9
+ # expect(vector.name).to eq(:uhura)
10
+ # end
11
+
12
+ # it "creates a vector object with a Hash with different values" do
13
+ # vector = Daru::Vector.new { sulu: MDArray.new([5], [1,2,3,4,5])}
14
+
15
+ # expect(vector[1]) .to eq(2)
16
+ # expect(vector.name).to eq(:sulu)
17
+ # end
18
+ # end
19
+ # end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::DataFrame do
4
+
5
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::Vector do
4
+ context "#initialize" do
5
+ it "creates a vector object with an Array" do
6
+ vector = Daru::Vector.new [1,2,3,4,5], :mowgli
7
+
8
+ expect(vector[1]) .to eq(2)
9
+ expect(vector.name).to eq(:mowgli)
10
+ end
11
+
12
+ it "creates a vector object with a Range" do
13
+ vector = Daru::Vector.new 1..5, :bakasur
14
+
15
+ expect(vector[1]) .to eq(2)
16
+ expect(vector.name).to eq(:bakasur)
17
+ end
18
+
19
+ it "creates a vector object with an NMatrix" do
20
+ vector = Daru::Vector.new(NMatrix.new([5], [1,2,3,4,5],
21
+ dtype: :int32), :scotty)
22
+
23
+ expect(vector[1]) .to eq(2)
24
+ expect(vector.name).to eq(:scotty)
25
+ end
26
+
27
+ it "creates a vector object with a Matrix" do
28
+ vector = Daru::Vector.new Matrix[[1,2,3,4,5]], :ravan
29
+
30
+ expect(vector[1]) .to eq(2)
31
+ expect(vector.name).to eq(:ravan)
32
+ end
33
+
34
+ it "creates a vector object with a Hash with different values" do
35
+ vector = Daru::Vector.new({orion: [1,2,3,4,5]})
36
+
37
+ expect(vector[1]) .to eq(2)
38
+ expect(vector.name).to eq(:orion)
39
+
40
+ vector = Daru::Vector.new({ kirk: 1..5 })
41
+
42
+ expect(vector[1]) .to eq(2)
43
+ expect(vector.name).to eq(:kirk)
44
+
45
+ vector = Daru::Vector.new({ spock: NMatrix.new([5], [1,2,3,4,5],
46
+ dtype: :int32) })
47
+
48
+ expect(vector[1]) .to eq(2)
49
+ expect(vector.name).to eq(:spock)
50
+ end
51
+
52
+ it "auto assigns a name if not specified" do
53
+ earth = Daru::Vector.new 1..5
54
+ organion = Daru::Vector.new 1..5
55
+
56
+ expect(earth.name == organion.name).to eq(false)
57
+ end
58
+ end
59
+
60
+ context "#each" do
61
+ it "executes the given block" do
62
+ sum = 0
63
+ vector = Daru::Vector.new 1..5, :mickey
64
+
65
+ vector.each{ |e| sum += e}
66
+
67
+ expect(sum).to eq(15)
68
+ end
69
+ end
70
+
71
+ context "#==" do
72
+ it "checks for equality of vectors" do
73
+ anakin = Daru::Vector.new 1..5, :anakin
74
+ luke = Daru::Vector.new 3..6, :luke
75
+
76
+ expect(anakin == luke).to be(false)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'nmatrix'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ require 'daru'
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daru
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sameer Deshmukh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nmatrix
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.0.rc5
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0.rc5
55
+ description: "Daru (Data Analysis in RUby) is a library for storage, analysis and
56
+ manipulation\nof data. It aims to be the preferred data storage library for all
57
+ Ruby gems, promoting \ninteroperability and easy of use between various ruby packages.\n"
58
+ email:
59
+ - sameer.deshmukh93@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".rspec"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE
68
+ - README.md
69
+ - daru.gemspec
70
+ - lib/daru.rb
71
+ - lib/daru/dataframe.rb
72
+ - lib/daru/vector.rb
73
+ - lib/version.rb
74
+ - spec/jruby/dataframe_spec.rb
75
+ - spec/jruby/vector_spec.rb
76
+ - spec/mri/dataframe_spec.rb
77
+ - spec/mri/vector_spec.rb
78
+ - spec/spec_helper.rb
79
+ homepage: http://github.com/v0dro/daru
80
+ licenses:
81
+ - BSD-2
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Data Analysis in RUby
103
+ test_files:
104
+ - spec/jruby/dataframe_spec.rb
105
+ - spec/jruby/vector_spec.rb
106
+ - spec/mri/dataframe_spec.rb
107
+ - spec/mri/vector_spec.rb
108
+ - spec/spec_helper.rb