Make scipy and pandas required dependencies

This commit is contained in:
Paul Romano 2017-06-02 06:41:20 -05:00
parent db3e6b7734
commit 1bd3e0b1d0
7 changed files with 18 additions and 47 deletions

View file

@ -401,14 +401,6 @@ distributions.
NumPy is used extensively within the Python API for its powerful
N-dimensional array.
`h5py <http://www.h5py.org/>`_
h5py provides Python bindings to the HDF5 library. Since OpenMC outputs
various HDF5 files, h5py is needed to provide access to data within these
files from Python.
.. admonition:: Optional
:class: note
`SciPy <https://www.scipy.org/>`_
SciPy's special functions, sparse matrices, and spatial data structures
are used for several optional features in the API.
@ -417,6 +409,14 @@ distributions.
Pandas is used to generate tally DataFrames as demonstrated in
:ref:`examples_pandas` example notebook.
`h5py <http://www.h5py.org/>`_
h5py provides Python bindings to the HDF5 library. Since OpenMC outputs
various HDF5 files, h5py is needed to provide access to data within these
files from Python.
.. admonition:: Optional
:class: note
`Matplotlib <http://matplotlib.org/>`_
Matplotlib is used to providing plotting functionality in the API like the
:meth:`Universe.plot` method and the :func:`openmc.plot_xs` function.

View file

@ -4,6 +4,7 @@ from collections import Iterable
from six import string_types
import numpy as np
import pandas as pd
import openmc
from openmc.filter import _FILTER_TYPES
@ -786,9 +787,6 @@ class AggregateFilter(object):
CrossFilter.get_pandas_dataframe()
"""
import pandas as pd
# Create NumPy array of the bin tuples for repeating / tiling
filter_bins = np.empty(self.num_bins, dtype=tuple)
for i, bin in enumerate(self.bins):

View file

@ -8,6 +8,7 @@ from xml.etree import ElementTree as ET
from six import add_metaclass
import numpy as np
import pandas as pd
import openmc
import openmc.checkvalue as cv
@ -460,9 +461,7 @@ class Filter(object):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
filter_bins = np.repeat(self.bins, self.stride)
@ -715,9 +714,7 @@ class SurfaceFilter(Filter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
filter_bins = np.repeat(self.bins, self.stride)
@ -875,9 +872,7 @@ class MeshFilter(Filter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
# Initialize dictionary to build Pandas Multi-index column
@ -1123,9 +1118,7 @@ class EnergyFilter(RealFilter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
# Extract the lower and upper energy bounds, then repeat and tile
@ -1335,9 +1328,7 @@ class DistribcellFilter(Filter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
level_df = None
@ -1531,9 +1522,7 @@ class MuFilter(RealFilter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
# Extract the lower and upper energy bounds, then repeat and tile
@ -1638,9 +1627,7 @@ class PolarFilter(RealFilter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
# Extract the lower and upper angle bounds, then repeat and tile
@ -1745,9 +1732,7 @@ class AzimuthalFilter(RealFilter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
# Initialize Pandas DataFrame
import pandas as pd
df = pd.DataFrame()
# Extract the lower and upper angle bounds, then repeat and tile
@ -2039,8 +2024,6 @@ class EnergyFunctionFilter(Filter):
Tally.get_pandas_dataframe(), CrossFilter.get_pandas_dataframe()
"""
import pandas as pd
df = pd.DataFrame()
# There is no clean way of sticking all the energy, y data into a

View file

@ -5,6 +5,9 @@ import os
from six import string_types
import numpy as np
import h5py
from scipy.interpolate import interp1d
from scipy.integrate import simps
from scipy.special import eval_legendre
import openmc
import openmc.mgxs
@ -1808,10 +1811,6 @@ class XSdata(object):
"""
from scipy.interpolate import interp1d
from scipy.integrate import simps
from scipy.special import eval_legendre
check_value('target_format', target_format, _SCATTER_TYPES)
check_type('target_order', target_order, Integral)
if target_format == 'legendre':

View file

@ -1,6 +1,8 @@
from collections import Callable
from numbers import Real
import scipy.optimize as sopt
import openmc
import openmc.model
import openmc.checkvalue as cv
@ -144,8 +146,6 @@ def search_for_keff(model_builder, initial_guess=None, target=1.0,
model = model_builder(initial_guess, **model_args)
cv.check_type('model_builder return', model, openmc.model.Model)
import scipy.optimize as sopt
# Set the iteration data storage variables
guesses = []
results = []

View file

@ -11,6 +11,8 @@ from xml.etree import ElementTree as ET
from six import string_types
import numpy as np
import pandas as pd
import scipy.sparse as sps
import h5py
import openmc
@ -295,8 +297,6 @@ 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 = \
@ -337,8 +337,6 @@ 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)
@ -361,8 +359,6 @@ 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)
@ -608,8 +604,6 @@ 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)
@ -1610,7 +1604,6 @@ class Tally(object):
raise KeyError(msg)
# Initialize a pandas dataframe for the tally data
import pandas as pd
df = pd.DataFrame()
# Find the total length of the tally data array

View file

@ -45,14 +45,12 @@ kwargs = {'name': 'openmc',
if have_setuptools:
kwargs.update({
# Required dependencies
'install_requires': ['six', 'numpy>=1.9', 'h5py'],
'install_requires': ['six', 'numpy>=1.9', 'h5py', 'scipy', 'pandas>=0.17.0'],
# Optional dependencies
'extras_require': {
'decay': ['uncertainties'],
'pandas': ['pandas>=0.17.0'],
'plot': ['matplotlib', 'ipython'],
'sparse' : ['scipy'],
'vtk': ['vtk', 'silomesh'],
'validate': ['lxml']
},