Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies = [
"Bug Tracker" = "https://github.com/CORE-GATECH-GROUP/serpent-tools/issues"

[project.optional-dependencies]
extras = ["pandas>1", "scipy"]
extras = ["pandas>1", "scipy>1.0"]
test = ["pytest>=8", "pytest-cov", "coverage"]
ci = ["jupyter"]

Expand Down
6 changes: 0 additions & 6 deletions src/serpentTools/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from abc import ABC, abstractmethod
from serpentTools.utils import checkScipy

__all__ = [
'MatlabConverter',
Expand Down Expand Up @@ -66,11 +65,6 @@ def checkContainerReq(self, container):
"Gathering method not implemented for {}."
.format(container.__class__.__name__))

def checkImports(self):
"""Ensure that :term:`scipy` >= 1.0 is installed."""
if not checkScipy('1.0'):
raise ImportError("scipy >= 1.0 required")

def convert(self, reconvert, append=True, format='5', longNames=True,
compress=True, oned='row'):
"""
Expand Down
13 changes: 9 additions & 4 deletions src/serpentTools/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
from serpentTools.messages import info
from serpentTools.settings import rc
from serpentTools.objects.base import BaseObject
from serpentTools.utils import checkScipy

try:
import scipy

_HAS_SCIPY = True
except ImportError:
_HAS_SCIPY = False


class BaseReader(ABC, BaseObject):
Expand Down Expand Up @@ -135,10 +141,9 @@ class SparseReaderMixin(object):
"""

def __init__(self, sparse):
HAS_SCIPY = checkScipy()
if sparse is None:
self.__sparse = HAS_SCIPY
elif sparse is True and not HAS_SCIPY:
self.__sparse = _HAS_SCIPY
elif sparse and not _HAS_SCIPY:
raise ImportError(
"scipy not installed and required for sparse support")
else:
Expand Down
12 changes: 0 additions & 12 deletions src/serpentTools/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
"""
Commonly used functions and utilities
"""
from distutils.version import StrictVersion

from serpentTools.utils.core import * # noqa
from serpentTools.utils.docstrings import * # noqa
from serpentTools.utils.compare import * # noqa
from serpentTools.utils.plot import * # noqa


def checkScipy(version=None):
"""Return ``True`` if the given version of :term:`scipy` is installed"""
try:
import scipy
except ImportError:
return False
if version is None:
return True
return StrictVersion(scipy.__version__) >= StrictVersion(version)
8 changes: 6 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from serpentTools.messages import (
DictHandler, __logger__, removeHandler, addHandler,
)
from serpentTools.utils import checkScipy


def computeMeansErrors(*arrays):
Expand Down Expand Up @@ -249,7 +248,12 @@ def assertMsgNotInLogs(self, level, msg, partial=False):
msg=failMsg.format(matchType, msg, level))


HAS_SCIPY = checkScipy('1.0')
try:
import scipy

HAS_SCIPY = True
except ImportError:
HAS_SCIPY = False


class MatlabTesterHelper(TestCase):
Expand Down