Skip to content

Commit

Permalink
Update4.1 handle num cpus (#669)
Browse files Browse the repository at this point in the history
* Handle or avoid multiprocessing import errors during qutip.__init__()
factorial import in utilities moved into only function that uses it
multiprocessing import in __init__ within try

* multiprocessing import moved outside the try
  • Loading branch information
ajgpitch committed Mar 16, 2017
1 parent 9fcf782 commit 9b1c13a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion qutip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
if 'cpus' in info:
qutip.settings.num_cpus = info['cpus']
else:
qutip.settings.num_cpus = multiprocessing.cpu_count()
try:
qutip.settings.num_cpus = multiprocessing.cpu_count()
except:
qutip.settings.num_cpus = 1


# Find MKL library if it exists
Expand Down
4 changes: 2 additions & 2 deletions qutip/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
'view_methods']

import numpy as np
from scipy.misc import factorial


def n_thermal(w, w_th):
"""
Expand Down Expand Up @@ -143,6 +141,8 @@ def clebsch(j1, j2, j3, m1, m2, m3):
Requested Clebsch-Gordan coefficient.
"""
from scipy.misc import factorial

if m3 != m1 + m2:
return 0
vmin = int(np.max([-j1 + j2 + m3, -j1 + m1, 0]))
Expand Down

0 comments on commit 9b1c13a

Please sign in to comment.