Skip to content

Commit

Permalink
let users use 1-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hie committed Jun 18, 2020
1 parent ba9687c commit 65f519b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ You should be able to install from PyPI:
pip install geosketch
```

**For an example of usage of `geosketch` in R using the [`reticulate`](https://rstudio.github.io/reticulate/) library, see [`example.R`](example.R). WARNING: The indices returned by `geosketch` are 0-indexed, but R uses 1 indexing.**

## API example usage

**Parameter documentation for the geometric sketching `gs()` function is in the source code at the top of [`geosketch/sketch.py`](geosketch/sketch.py).**

**For an example of usage of `geosketch` in R using the [`reticulate`](https://rstudio.github.io/reticulate/) library, see [`example.R`](example.R). WARNING: The indices returned by `geosketch` are 0-indexed, but R uses 1-indexing, so the `one_indexed` parameter should be set to `TRUE` when called from R.**

Here is example usage of `geosketch` in Python. First, put your data set into a matrix:
```
X = [ sparse or dense matrix, samples in rows, features in columns ]
Expand Down
6 changes: 3 additions & 3 deletions example.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WARNING: Sketch indices returned by geosketch are 0-indexed but R
# uses 1-indexing; indices should be shifted by 1 for any downstream
# analysis!
# uses 1-indexing; indices should be shifted by 1 by setting
# `one_indexed = TRUE` for any downstream analysis.

library(reticulate)
library(rsvd)
Expand All @@ -16,5 +16,5 @@ X.pcs <- s$u %*% diag(s$d)

# Sketch 10% of data.
sketch.size <- as.integer(100)
sketch.indices <- geosketch$gs(X.pcs, sketch.size)
sketch.indices <- geosketch$gs(X.pcs, sketch.size, one_indexed = TRUE)
print(sketch.indices)
2 changes: 2 additions & 0 deletions geosketch/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .sketch import *

__version__ = '1.1'
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

setup(
name='geosketch',
version='1.0',
version='1.1',
description='Geometry-preserving random sampling',
url='https://github.com/brianhie/geosketch',
download_url='https://github.com/brianhie/geosketch/archive/v1.0.tar.gz',
download_url='https://github.com/brianhie/geosketch/archive/v1.1.tar.gz',
packages=find_packages(exclude=['bin', 'conf', 'data', 'target', 'R']),
install_requires=[
'fbpca>=1.0',
Expand Down

0 comments on commit 65f519b

Please sign in to comment.