Skip to content

Commit

Permalink
Rearrange dependencies, make some optional
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Jul 6, 2023
1 parent e85e605 commit c702e37
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/unittest.yml
Expand Up @@ -18,18 +18,6 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.9, "3.10", "3.11"]
# exclude:
# # excludes py38 on macOS, which seems to stall currently
# - os: macos-latest
# python-version: 3.8
# - os: macos-latest
# python-version: 3.9
# - os: macos-latest
# python-version: "3.10"
# - os: macos-latest
# python-version: "3.11"
# - os: windows-latest
# python-version: "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
3 changes: 0 additions & 3 deletions environment.yml
Expand Up @@ -20,7 +20,6 @@ dependencies:
- tinydb
- periodictable
- mpltern>=0.4.0
- mpmath
- sympy>=1.7 # import changes after sympy 1.6
- joblib
- requests
Expand All @@ -35,8 +34,6 @@ dependencies:
- pip
- black
- isort
- jedi<0.18.0 # for use on atom/ipython
- pyzmq
- pytest
- pytest-runner
- pytest-cov
Expand Down
12 changes: 9 additions & 3 deletions pyrolite/util/spatial.py
Expand Up @@ -4,7 +4,11 @@
import itertools

import numpy as np
from psutil import virtual_memory # memory check

try:
from psutil import virtual_memory # memory check
except ImportError:
virtual_memory = None

from .log import Handle

Expand Down Expand Up @@ -176,14 +180,16 @@ def great_circle_distance(
# but, with large arrays it'll spit out a memory error
# so instead we can try to build it numerically
size = np.max([a.shape[0] for a in [φ1, φ2, λ1, λ2]])
mem = virtual_memory().total # total physical memory available
estimated_matrix_size = np.array([[1.0]], dtype=dtype).nbytes * size**2
logger.debug(
"Attempting to build {}x{} array of size {:.2f} Gb.".format(
size, size, estimated_matrix_size / 1024**3
)
)
if estimated_matrix_size > (mem * max_memory_fraction):

infeasible = estimated_matrix_size > (virtual_memory().total * max_memory_fraction) if virtual_memory is not None else False

if infeasible:
logger.warn(
"Angle array for segmented distance matrix larger than maximum memory "
"fraction, computing mean global distances instead."
Expand Down
12 changes: 4 additions & 8 deletions setup.py
Expand Up @@ -15,9 +15,10 @@
]
dev_require = ["pytest", "versioneer", "black", "isort", "twine"] + tests_require + docs_require
db_require = ["pyodbc", "psycopg2"]
skl_require = ["scikit-learn"]
skl_require = ["scikit-learn", "joblib"]
stats_require = ["statsmodels", "scikit-learn"]
spatial_require = ["owslib", "geojson"] # this needs pyproj -> C compiler
spatial_require = ["owslib", "geojson", "psutil"] # this needs pyproj -> C compiler
excel_require = ["xlrd", "openpyxl"] # reading excel from pandas, writing excel from pandas

with open("README.md", "r") as src:
LONG_DESCRIPTION = src.read()
Expand Down Expand Up @@ -56,18 +57,12 @@
"numpy",
"numpydoc",
"tinydb>4.1", # >4.1 required for read-only access mode for JSON storage
"typing-extensions", # required for newer tinydb versions?
"psutil",
"periodictable",
"matplotlib",
"mpltern>=0.4.0",
"scipy>=1.2", # uses scipy.optimize.Bounds, added around 1.2
"mpmath",
"sympy>=1.7",
"pandas>=1.0", # dataframe acccessors, attrs attribute
"xlrd", # reading excel from pandas
"openpyxl", # writing excel from pandas
"joblib",
"requests", # used by alphaMELTS utilities, util.web
],
extras_require={
Expand All @@ -77,6 +72,7 @@
"spatial": spatial_require,
"db": db_require,
"stats": stats_require,
"excel": excel_require
},
tests_require=tests_require,
test_suite="test",
Expand Down

0 comments on commit c702e37

Please sign in to comment.