Skip to content

Commit cc81424

Browse files
committed
Added changelog, created v1.x and 2.0 plan, added logo, added pr template, changed license, changed stat attr_writer x methods to automatically standardize
1 parent b342c3a commit cc81424

21 files changed

+304
-73
lines changed

.github/pull_request_template.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixes #
2+
3+
## Proposed Changes
4+
5+
## Additional Info

CHANGELOG.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.0.3] - 2020-05-22
11+
12+
### Added
13+
14+
- CONTRIBUTING.md
15+
- PR Template
16+
- logo
17+
18+
### Changed
19+
20+
- `x/z` attr_writer changed to a function that standardizes input
21+
- MIT -> GPL-3-Clause License
22+
23+
## [1.0.2] - 2020-05-08 (First Changelog Commit)
24+
25+
### Added
26+
27+
- Global Statistical Classes
28+
- Local Statistical Classes
29+
- WeightsMatrix
30+
- Weights Queries
31+
- Data queries
32+
- Spatial Lag computations
33+
- Array extensions
34+
- Numo extensions
35+
- Add examples/usage to docs
36+
- Create RDocs
37+
- Write SparseMatrix C ext
38+
- Add `#summary` method to statistics that will combine stat vals with p-vals, and quads or hot/cold spot info.
39+
- Add ability to assign `x` or `z` on stat classes so users are not forced to query data to input it into models. Add example to README.
40+
41+
### Changed
42+
43+
- Memoize expensive functions within classes
44+
- Make star a parameter to getis-ord class
45+
- Refactor Global Moran and BVMoran
46+
- Support non-numeric keys in WeightsMatrix/General refactor
47+
- Change instances of `standardized` and `windowed` to `standardize` and `window`, respectively.
48+
- Add `positive` and `negative` groups for `GetisOrd` and `Geary`, similar to how `#quads` is implemented.
49+
- Refactor stats to inherit an abstract class.
50+
51+
### Removed
52+
53+
- Pure Ruby CSR Matrix
54+
55+
[unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.3...HEAD
56+
[1.0.3]: https://github.com/keithdoggett/spatial_stats/compare/v1.0.1...v1.0.3
57+
[1.0.2]: https://github.com/keithdoggett/spatial_stats/compare/v1.0.1...v1.0.2
58+
[1.0.1]: https://github.com/keithdoggett/spatial_stats/compare/v1.0.0...v1.0.1
59+
[1.0.0]: https://github.com/keithdoggett/spatial_stats/compare/v0.2.2...v1.0.0
60+
[0.2.2]: https://github.com/keithdoggett/spatial_stats/compare/v0.2.1...v0.2.2
61+
[0.2.1]: https://github.com/keithdoggett/spatial_stats/compare/v0.1.1...v0.2.1
62+
[0.1.1]: https://github.com/keithdoggett/spatial_stats/compare/v0.1.0...v0.1.1
63+
[0.1.0]: https://github.com/keithdoggett/spatial_stats/releases/tag/v0.1.0

CONTRIBUTING.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Contributing
2+
3+
Once cloned, run the following commands to setup the test database.
4+
5+
```bash
6+
cd ./spatial_stats
7+
bundle install
8+
cd test/dummy
9+
rake db:create
10+
rake db:migrate
11+
```
12+
13+
If you are getting an error, you may need to set the following environment variables.
14+
15+
```bash
16+
$PGUSER # default "postgres"
17+
$PGPASSWORD # default ""
18+
$PGHOST # default "127.0.0.1"
19+
$PGPORT # default "5432"
20+
$PGDATABASE # default "spatial_stats_test"
21+
```
22+
23+
If the dummy app is setup correctly, run the following:
24+
25+
```bash
26+
cd ../..
27+
rake
28+
```
29+
30+
This will run the tests. If they all pass, then your environment is setup correctly.
31+
32+
Note: It is recommended to have GEOS installed and linked to RGeo. You can test this by running the following:
33+
34+
```bash
35+
cd test/dummy
36+
rails c
37+
38+
RGeo::Geos.supported?
39+
# => true
40+
```
41+
42+
Please submit PRs with a description of the problem, the solution and link any issues that it closes.

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
spatial_stats (1.0.2)
4+
spatial_stats (1.0.3)
55
numo-narray (~> 0.9.1)
66
rails (~> 6.0.0)
77

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020 Keith Doggett.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MIT-LICENSE

-20
This file was deleted.

README.md

+25-43
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![Build Status](https://travis-ci.com/keithdoggett/spatial_stats.svg?branch=master)](https://travis-ci.com/keithdoggett/spatial_stats)
22

3+
![Spatial Stats](/assets/ruby.svg)
4+
35
# SpatialStats
46

57
SpatialStats is an ActiveRecord plugin that utilizes PostGIS and Ruby to compute weights/statistics of spatial data sets in Rails Apps.
@@ -138,8 +140,8 @@ field = nil
138140
moran = SpatialStats::Global::Moran.new(scope, field, weights)
139141
# => <SpatialStats::Global::Moran>
140142

141-
# important to standardize the data!
142-
data = [1,2,3,4,5,6].standardize
143+
# data is automatically standardized on input
144+
data = [1,2,3,4,5,6]
143145
moran.x = data
144146

145147
moran.stat
@@ -219,8 +221,8 @@ field = nil
219221
moran = SpatialStats::Local::Moran.new(scope, field, weights)
220222
# => <SpatialStats::Local::Moran>
221223

222-
# important to standardize the data!
223-
data = [1,2,3,4,5,6].standardize
224+
# data is automatically standardized on input
225+
data = [1,2,3,4,5,6]
224226
moran.x = data
225227

226228
moran.stat
@@ -310,50 +312,30 @@ RGeo::Geos.supported?
310312
# => true
311313
```
312314

313-
## TODO
314-
315-
- ~~Memoize expensive functions within classes~~
316-
- ~~Make star a parameter to getis-ord class~~
317-
- ~~Add examples/usage to docs~~
318-
- ~~Create RDocs~~
319-
- ~~Refactor Global Moran and BVMoran~~
320-
- ~~Support non-numeric keys in WeightsMatrix/General refactor~~
321-
- ~~Write SparseMatrix C ext~~
322-
- ~~Change instances of `standardized` and `windowed` to `standardize` and `window`, respectively.~~
323-
- ~~Add `positive` and `negative` groups for `GetisOrd` and `Geary`, similar to how `#quads` is implemented.~~
324-
- ~~Add `#summary` method to statistics that will combine stat vals with p-vals, and quads or hot/cold spot info.~~
325-
- ~~Add ability to assign `x` or `z` on stat classes so users are not forced to query data to input it into models. Add example to README.~~
326-
327-
## Future Work
328-
329-
#### General
330-
331-
- ~~Refactor stats to inherit an abstract class.~~
332-
- ~~Change WeightsMatrix class and Stat classes to utilize sparse matrix methods.~~
333-
- Split into two separate gems spatial_stats and spatial_stats-activerecord
334-
335-
#### Weights
336-
337-
- Add Kernel based weighting
338-
339-
#### Utils
340-
341-
- Rate smoothing
342-
- Bayes smoothing
343-
344-
#### Global
315+
## Path Forward
345316

346-
- Geary class
347-
- GetisOrd class
317+
Summaries of milestones for v1.x and v2.0. These lists are subject to change. If you have an additional feature you want to see for either milestone, open up an issue or PR.
348318

349-
#### Local
319+
### v1.x
350320

351-
- Join Count Statistic
321+
1. Global Measurements
322+
- `Geary`'s C
323+
- `GetisOrd`
324+
2. Local Measurements
325+
- `Join Count`
326+
3. Utilities
327+
- Add support for .gal/.swm file imports
328+
- Add support for Rate variables
329+
- Add support for Bayes smoothing
330+
4. General
331+
- Point Pattern Analysis Module
332+
- Regression Module
352333

353-
#### PPA
334+
### v2.0
354335

355-
- Add descriptive stat methods for point clusters.
336+
- Break gem into core `spatial_stats` that will not include queries module and `spatial_stats-activerecord`. This will remove the dependency on rails for the core gem.
337+
- Create `spatial_stats-import/geojson/shp` gem that will allow importing files and generating a `WeightsMatrix`. Will likely rely on `RGeo` or another spatial lib.
356338

357339
## License
358340

359-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
341+
The gem is available as open source under the terms of the [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause).

assets/ruby.svg

+84
Loading

lib/spatial_stats/global/bivariate_moran.rb

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def initialize(scope, x_field, y_field, weights)
2121
@y_field = y_field
2222
@weights = weights.standardize
2323
end
24-
attr_writer :x, :y
2524

2625
##
2726
# Computes the global spatial correlation of x against spatially lagged

lib/spatial_stats/global/moran.rb

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Moran < Stat
1818
def initialize(scope, field, weights)
1919
super(scope, field, weights)
2020
end
21-
attr_writer :x
2221

2322
##
2423
# Computes the global spatial autocorrelation of x against a spatially

lib/spatial_stats/global/stat.rb

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ def z_score
3939
(stat - expectation) / Math.sqrt(variance)
4040
end
4141

42+
def x=(values)
43+
@x = values.standardize
44+
end
45+
alias z= x=
46+
47+
def y=(values)
48+
@y = values.standardize
49+
end
50+
4251
def mc(permutations, seed)
4352
rng = gen_rng(seed)
4453
shuffles = []

lib/spatial_stats/local/bivariate_moran.rb

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def initialize(scope, x_field, y_field, weights)
2222
@weights = weights.standardize
2323
end
2424
attr_accessor :scope, :x_field, :y_field, :weights
25-
attr_writer :x, :y
2625

2726
##
2827
# Computes the local indicator of spatial correlation for

0 commit comments

Comments
 (0)