mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Made SciPy imports for sparse tallies optional
This commit is contained in:
parent
d2c9e18082
commit
3eb10519ac
2 changed files with 11 additions and 2 deletions
|
|
@ -10,7 +10,6 @@ from xml.etree import ElementTree as ET
|
|||
import sys
|
||||
|
||||
import numpy as np
|
||||
import scipy.sparse as sps
|
||||
|
||||
from openmc import Mesh, Filter, Trigger, Nuclide
|
||||
from openmc.cross import CrossScore, CrossNuclide, CrossFilter
|
||||
|
|
@ -323,6 +322,8 @@ class Tally(object):
|
|||
|
||||
# Convert NumPy arrays to SciPy sparse LIL matrices
|
||||
if self.sparse:
|
||||
import scipy.sparse as sps
|
||||
|
||||
self._sum = \
|
||||
sps.lil_matrix(self._sum.flatten(), self._sum.shape)
|
||||
self._sum_sq = \
|
||||
|
|
@ -363,6 +364,8 @@ class Tally(object):
|
|||
|
||||
# Convert NumPy array to SciPy sparse LIL matrix
|
||||
if self.sparse:
|
||||
import scipy.sparse as sps
|
||||
|
||||
self._mean = \
|
||||
sps.lil_matrix(self._mean.flatten(), self._mean.shape)
|
||||
|
||||
|
|
@ -385,6 +388,8 @@ class Tally(object):
|
|||
|
||||
# Convert NumPy array to SciPy sparse LIL matrix
|
||||
if self.sparse:
|
||||
import scipy.sparse as sps
|
||||
|
||||
self._std_dev = \
|
||||
sps.lil_matrix(self._std_dev.flatten(), self._std_dev.shape)
|
||||
|
||||
|
|
@ -550,6 +555,8 @@ class Tally(object):
|
|||
|
||||
# Convert NumPy arrays to SciPy sparse LIL matrices
|
||||
if sparse and not self.sparse:
|
||||
import scipy.sparse as sps
|
||||
|
||||
if self._sum is not None:
|
||||
self._sum = \
|
||||
sps.lil_matrix(self._sum.flatten(), self._sum.shape)
|
||||
|
|
@ -562,6 +569,7 @@ class Tally(object):
|
|||
if self._std_dev is not None:
|
||||
self._std_dev = \
|
||||
sps.lil_matrix(self._std_dev.flatten(), self._std_dev.shape)
|
||||
|
||||
self._sparse = True
|
||||
|
||||
# Convert SciPy sparse LIL matrices to NumPy arrays
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -32,11 +32,12 @@ kwargs = {'name': 'openmc',
|
|||
if have_setuptools:
|
||||
kwargs.update({
|
||||
# Required dependencies
|
||||
'install_requires': ['numpy', 'h5py', 'matplotlib', 'scipy'],
|
||||
'install_requires': ['numpy', 'h5py', 'matplotlib'],
|
||||
|
||||
# Optional dependencies
|
||||
'extras_require': {
|
||||
'pandas': ['pandas'],
|
||||
'sparse' : ['scipy'],
|
||||
'vtk': ['vtk', 'silomesh'],
|
||||
'validate': ['lxml']
|
||||
}})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue