-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Wytamma/pyLangevitour
Python interface for langevitour contributed by Wytamma Wirth.
- Loading branch information
Showing
16 changed files
with
878 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,8 @@ inst/doc | |
docs | ||
/doc/ | ||
/Meta/ | ||
|
||
# python | ||
*.pyc | ||
dist | ||
.ipynb_checkpoints/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: langevitour | ||
Title: Langevin Tour | ||
Version: 0.5.2 | ||
Version: 0.5.5 | ||
Authors@R: | ||
person("Paul", "Harrison", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-3980-268X")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dependencies: | ||
- name: langevitour | ||
version: "0.5.2" | ||
version: "0.5.5" | ||
src: htmlwidgets/lib/ | ||
script: | ||
- langevitour-pack.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# langevitour for Python | ||
|
||
[![PyPI - Version](https://img.shields.io/pypi/v/langevitour.svg)](https://pypi.org/project/langevitour) | ||
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/langevitour.svg)](https://pypi.org/project/langevitour) | ||
|
||
Python interface for [langevitour](https://github.com/pfh/langevitour/) a HTML widget that randomly tours projections of a high-dimensional dataset with an animated scatter-plot. | ||
|
||
For more information see the langevitour [Github repo](https://github.com/pfh/langevitour) or [website](https://logarithmic.net/langevitour/). | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install langevitour | ||
``` | ||
|
||
## Python usage | ||
|
||
```python | ||
import numpy as np | ||
|
||
from langevitour import Langevitour | ||
|
||
# Generate a sample dataset | ||
X = [] | ||
group = [] | ||
n = 20000 | ||
|
||
def r(): | ||
return np.random.normal(0, 0.02) | ||
|
||
for i in range(n): | ||
a = i/n * np.pi * 2 | ||
X.append([ | ||
10 + np.sin(a)/3 + r(), | ||
20 + np.sin(a*2)/3 + r(), | ||
30 + np.sin(a*3)/3, | ||
40 + np.sin(a*4)/3, | ||
50 + np.sin(a*5)/3 | ||
]) | ||
group.append(int(i*4/n)) | ||
|
||
# Extra axes (specified as columns of a matrix) | ||
extra_axes = [[1], [2], [0], [0], [0]] | ||
extra_axes_names = ["V1+2*V2"] | ||
|
||
tour = Langevitour( | ||
X, | ||
group=group, | ||
extra_axes=extra_axes, | ||
extra_axes_names=extra_axes_names, | ||
point_size=1, | ||
) | ||
tour.write_html("langevitour_plot.html") | ||
``` | ||
|
||
langevitour also works in [jupyter notebooks](https://colab.research.google.com/github/pfh/langevitour/blob/main/py/examples/langevitour.ipynb). |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
|
||
from langevitour import Langevitour | ||
|
||
# Generate a sample dataset | ||
X = [] | ||
group = [] | ||
n = 20000 | ||
|
||
def r(): | ||
return np.random.normal(0, 0.02) | ||
|
||
for i in range(n): | ||
a = i/n * np.pi * 2 | ||
X.append([ | ||
10 + np.sin(a)/3 + r(), | ||
20 + np.sin(a*2)/3 + r(), | ||
30 + np.sin(a*3)/3, | ||
40 + np.sin(a*4)/3, | ||
50 + np.sin(a*5)/3 | ||
]) | ||
group.append(int(i*4/n)) | ||
|
||
# Extra axes (specified as columns of a matrix) | ||
extra_axes = [[1], [2], [0], [0], [0]] | ||
extra_axes_names = ["V1+2*V2"] | ||
|
||
tour = Langevitour( | ||
X, | ||
group=group, | ||
extra_axes=extra_axes, | ||
extra_axes_names=extra_axes_names, | ||
point_size=1, | ||
) | ||
tour.write_html("langevitour_plot.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2023-present Wytamma Wirth <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
__version__ = "0.5.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2023-present Wytamma Wirth <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
from .langevitour import Langevitour |
Oops, something went wrong.