cre_property_matcher 0.0.11 → 0.1.1
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.
- checksums.yaml +4 -4
- data/lib/cre_property_matcher/property.rb +2 -1
- data/lib/cre_property_matcher/property_data_calculator.rb +10 -2
- data/lib/cre_property_matcher/version.rb +1 -1
- data/test/cre_property_matcher/property_data_calculator_test.rb +30 -0
- data/test/cre_property_matcher_test.rb +12 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89f865fd1d890cabf7443696e7df8fce9e8806e
|
4
|
+
data.tar.gz: 88f94b41f8e8bac3d95cce5948eba52484af5a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6870afb4e23a0790980c0e6202a17efcb1932b0b41f92dcb7152d52ce27c6769d52cfd7aed9cd53c10a2cd90b920998504fd7d3abae2a0e2a2c94352f97ddf
|
7
|
+
data.tar.gz: d0d9334cc6610b83ec82d10704e1c5eb00a6bd47cb59d9ddb29b68c6e18c6e478ad0ab4c5ee0aac5b197d8c2a14d3e41a0b9a3090a5facbac9a08ef0372be49d
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "csv"
|
1
2
|
require "date"
|
2
3
|
require File.expand_path("../property_attributes.rb", __FILE__)
|
3
4
|
|
@@ -126,7 +127,7 @@ class Property
|
|
126
127
|
end
|
127
128
|
|
128
129
|
def clean_money(value)
|
129
|
-
value.strip.delete("$").delete(",").to_i if value
|
130
|
+
value.to_s.strip.delete("$").delete(",").to_i if value
|
130
131
|
end
|
131
132
|
|
132
133
|
def validate_hash(hash)
|
@@ -4,8 +4,12 @@ module PropertyDataCalculator
|
|
4
4
|
def get_average_by_reference_property_state(properties, reference, attribute)
|
5
5
|
state_properties = filter_properties_by_state(properties, reference.state)
|
6
6
|
values_array = get_attribute_from_properties(state_properties, attribute)
|
7
|
-
|
8
|
-
|
7
|
+
float_average_of_array(values_array)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_average_for_all(properties, attribute)
|
11
|
+
values_array = get_attribute_from_properties(properties, attribute)
|
12
|
+
float_average_of_array(values_array)
|
9
13
|
end
|
10
14
|
|
11
15
|
private
|
@@ -37,4 +41,8 @@ module PropertyDataCalculator
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
44
|
+
def float_average_of_array(array)
|
45
|
+
total = array.compact.reduce(:+)
|
46
|
+
total.to_f / array.count
|
47
|
+
end
|
40
48
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require File.expand_path("../../../lib/cre_property_matcher/property.rb", __FILE__)
|
3
|
+
require File.expand_path("../../../lib/cre_property_matcher/property_data_calculator.rb", __FILE__)
|
4
|
+
|
5
|
+
class TestPropertyDataCalculator < Minitest::Test
|
6
|
+
include PropertyDataCalculator
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@properties = []
|
10
|
+
|
11
|
+
states_array = ["OH", "OH", "NJ", "CT", "OH"]
|
12
|
+
|
13
|
+
[1,2,3,4,5].each do |n|
|
14
|
+
@properties << Property.new({noi: n, ncf: n, uw_expenses: n, uw_revenue: n, state: states_array[n - 1]})
|
15
|
+
end
|
16
|
+
|
17
|
+
@properties
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_get_average_for_all
|
21
|
+
result = get_average_for_all(@properties, "noi")
|
22
|
+
assert_equal 3, result
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_average_by_reference_property_state
|
26
|
+
reference = {noi: 1, ncf: 2, uw_expenses: 3, uw_revenue: 4, state: "OH"}
|
27
|
+
result = get_average_by_reference_property_state(@properties, Property.new(reference), "noi")
|
28
|
+
assert_equal (8/3.0), result
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require File.expand_path("../../lib/cre_property_matcher.rb", __FILE__)
|
3
|
+
|
4
|
+
class TestCrePropertyMatcher < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@pm = CrePropertyMatcher::PropertyMatcher.new(noi: "400,000", ncf: "387,000", ltv: "75%", general_property_type: "Retail", appraised_value: "5,000,000", occupancy: "94%", uw_revenue: "500,000", uw_expenses: "145,000", state: "CT")
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_reference_property_instantiated
|
10
|
+
assert_equal false, @pm.reference.nil?
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cre_property_matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Arner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,8 @@ files:
|
|
60
60
|
- lib/cre_property_matcher/resources/state_hash.rb
|
61
61
|
- lib/cre_property_matcher/training_data/property_data.csv
|
62
62
|
- lib/cre_property_matcher/version.rb
|
63
|
+
- test/cre_property_matcher/property_data_calculator_test.rb
|
64
|
+
- test/cre_property_matcher_test.rb
|
63
65
|
homepage: ''
|
64
66
|
licenses:
|
65
67
|
- MIT
|
@@ -85,4 +87,6 @@ signing_key:
|
|
85
87
|
specification_version: 4
|
86
88
|
summary: A basic implementation of the kNN Machine Learning Algorithm for Commercial
|
87
89
|
Real Estate Analysis
|
88
|
-
test_files:
|
90
|
+
test_files:
|
91
|
+
- test/cre_property_matcher/property_data_calculator_test.rb
|
92
|
+
- test/cre_property_matcher_test.rb
|