Skip to content

Commit

Permalink
Dwr/better error handling (#8)
Browse files Browse the repository at this point in the history
* Better error handling if openmp not available.

* Add requirement on openmp
  • Loading branch information
rappdw authored and mikekwright committed Aug 21, 2018
1 parent 22c0e2c commit 1c44303
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ This library has been added to pypi as tsne-mp
pip install tsne-mp
```

It requires openmp support.
* OSX - `brew install libomp`
* linux - 'sudo apt-get install libgomp1'
* Windows - Included with Visual Studio C++

## Usage

Basic usage:
Expand Down
20 changes: 18 additions & 2 deletions tsne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@
from __future__ import division
import numpy as np
import scipy.linalg as la
from tsne.bh_sne import BH_SNE
from tsne.bh_sne_3d import BH_SNE_3D
try:
from tsne.bh_sne import BH_SNE
from tsne.bh_sne_3d import BH_SNE_3D
except ImportError as e:
import sys
if sys.platform == 'darwin':
raise ImportError('''
Unable to import likely due to missing openmp. Try: 'brew install libomp'
''') from e
elif sys.platform == 'win32':
raise ImportError('''
Unable to import likely due to missing openmp. Ensure openmp support is installed.'
''') from e
else:
raise ImportError('''
Unable to import likely due to missing openmp. Try: 'sudo apt-get install libgomp1'
''') from e


def bh_sne(data, pca_d=None, d=2, perplexity=30., theta=0.5,
random_state=None, copy_data=False, init=None,
Expand Down

0 comments on commit 1c44303

Please sign in to comment.