From 0ea75b62351f1b6d829bffd0835599ad0a47a3f3 Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Fri, 24 Feb 2023 11:46:33 +1100 Subject: [PATCH 1/3] Remove scipy dependency by replacing eigvals() function --- anastruct/fem/system_components/solver.py | 4 ++-- dev_requirements.txt | 3 +-- requirements.txt | 1 - requirements_docs.txt | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/anastruct/fem/system_components/solver.py b/anastruct/fem/system_components/solver.py index 633fea0f..d4822709 100644 --- a/anastruct/fem/system_components/solver.py +++ b/anastruct/fem/system_components/solver.py @@ -2,7 +2,6 @@ import logging from typing import TYPE_CHECKING, Optional import numpy as np -from scipy import linalg # type: ignore from anastruct.basic import converge @@ -109,7 +108,8 @@ def det_linear_buckling(system: "SystemElements") -> float: kg = system.reduced_system_matrix - k0 # solve (k -λkg)x = 0 - eigenvalues = np.abs(linalg.eigvals(k0, kg)) + invkg_k0 = np.linalg.inv(kg) * k0 + eigenvalues = np.abs(np.linalg.eigvals(invkg_k0)) return float(np.min(eigenvalues)) diff --git a/dev_requirements.txt b/dev_requirements.txt index 7b08d321..f993d963 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,3 +1,2 @@ matplotlib==3.7.0 -numpy==1.24.2 -scipy==1.10.1 \ No newline at end of file +numpy==1.24.2 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1101330e..949e5884 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ numpy>=1.15 -scipy>=1.1.0 diff --git a/requirements_docs.txt b/requirements_docs.txt index 5ae95cf5..5253f8c9 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,3 +1,2 @@ -scipy matplotlib sphinx_autodoc_typehints From 8d5582cd12b64088ba33bca8a5057239f0bc4cef Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Fri, 24 Feb 2023 11:53:13 +1100 Subject: [PATCH 2/3] Add comment to clarify the change --- anastruct/fem/system_components/solver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/anastruct/fem/system_components/solver.py b/anastruct/fem/system_components/solver.py index d4822709..50fa3ada 100644 --- a/anastruct/fem/system_components/solver.py +++ b/anastruct/fem/system_components/solver.py @@ -108,6 +108,9 @@ def det_linear_buckling(system: "SystemElements") -> float: kg = system.reduced_system_matrix - k0 # solve (k -λkg)x = 0 + # The following two lines are equivalent to the cleaner + # scipy.linalg.eigvals(k0, kg), but doing this allows us + # to drop the scipy dependency invkg_k0 = np.linalg.inv(kg) * k0 eigenvalues = np.abs(np.linalg.eigvals(invkg_k0)) return float(np.min(eigenvalues)) From cf8b25a8d2879309318bbf008da8a519bcb98b55 Mon Sep 17 00:00:00 2001 From: Brooks Smith <42363318+smith120bh@users.noreply.github.com> Date: Sat, 6 Jun 2026 20:21:54 +1000 Subject: [PATCH 3/3] Actually remove the scipy dependency, update install docs --- anastruct/fem/system_components/solver.py | 6 +- docs/source/installation.rst | 31 ++++------ poetry.lock | 70 +---------------------- pyproject.toml | 2 - 4 files changed, 18 insertions(+), 91 deletions(-) diff --git a/anastruct/fem/system_components/solver.py b/anastruct/fem/system_components/solver.py index c758b1ea..c740fa9d 100644 --- a/anastruct/fem/system_components/solver.py +++ b/anastruct/fem/system_components/solver.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Optional import numpy as np + from anastruct.basic import converge if TYPE_CHECKING: @@ -111,8 +112,9 @@ def det_linear_buckling(system: "SystemElements") -> float: # solve (k -λkg)x = 0 # The following two lines are equivalent to the cleaner - # scipy.linalg.eigvals(k0, kg), but doing this allows us - # to drop the scipy dependency + # `scipy.linalg.eigvals(k0, kg)``, but doing this in numpy + # instead allows us to drop the very heavy scipy dependency + # that was needed for no other reason than this one line. invkg_k0 = np.linalg.inv(kg) * k0 eigenvalues = np.abs(np.linalg.eigvals(invkg_k0)) return float(np.min(eigenvalues)) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 1f9dbb46..3892da49 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -1,7 +1,7 @@ Installation ############ -You will need Python and a few packages as pre-requisites of the anaStruct on your system. +You will need Python to install anaStruct on your system. Install the Python @@ -21,12 +21,12 @@ In case you are missing the python on your system, you can install it from the r :: sudo apt-get update - sudo apt-get install python3.9 + sudo apt-get install python3 Windows ======= -On windows (and for other OS's too) you can download the installation source of the version you prefer from the `Python's website `_. You can choose between the various versions and cpu architectures. +On Windows (and for other OS's) you can download the installer for the version you prefer from `Python's website `_. Mac ===== @@ -37,34 +37,25 @@ For Mac OS install Python 3 using homebrew brew install python -Install the prerequisites -************************* +Install anaStruct +***************** -You will need the `NumPy `_ and `SciPy `_. packages to be able to use the anaStruct package. However, if you are using the pip to install the package, it will take care of all dependencies and their versions. +anaStruct is a lightweight package with only one mandatory prerequisite: `numpy`. If you want to use the plotting features of the package, then you will also need `matplotlib`. The installation process will automatically install these dependencies for you. -Install the anaStruct -********************* - -You can install anaStruct with pip! If you like to use the computational backend of the package without having the plotting features, simply run the code below in the terminal. Pip will install a headless version of anaStruct (with no plotting abilities). +If you like to use the computational backend of the package without having the plotting features, simply run the code below in the terminal. Pip will install a headless version of anaStruct (with no plotting abilities). :: - python -m pip install anastruct + pip install anastruct Otherwise you can have a full installation using the following code in your terminal. :: - python -m pip install anastruct[plot] - -In case you need a specific version of the package, that's possible too. Simple declare the version condition over the code in terminal. - -:: - - python -m pip install anastruct==1.4.1 + pip install anastruct[plot] -Alternatively, you can build the package from the source by cloning the source from the git repository. Updates are made regularly released on `PyPi `_, and if you'd like the bleeding edge newest features and fixes, or if you'd like to contribute to the development of `anaStruct `_, then install from github. +Alternatively, you can build the package from source by cloning the source from the git repository. Updates are regularly released on `PyPi `_, but if you'd like the bleeding edge newest features and fixes, or if you'd like to contribute to the development of `anaStruct `_, then install from github. :: - pip install git+https://github.com/ritchie46/anaStruct.git \ No newline at end of file + pip install git+https://github.com/anastruct/anaStruct.git \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 9c88351b..3bdcd732 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. [[package]] name = "alabaster" @@ -1653,8 +1653,8 @@ astroid = ">=4.0.2,<=4.1.dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ {version = ">=0.2", markers = "python_version < \"3.11\""}, - {version = ">=0.3.6", markers = "python_version == \"3.11\""}, {version = ">=0.3.7", markers = "python_version >= \"3.12\""}, + {version = ">=0.3.6", markers = "python_version == \"3.11\""}, ] isort = ">=5,<5.13 || >5.13,<9" mccabe = ">=0.6,<0.8" @@ -1938,70 +1938,6 @@ socks = ["PySocks (>=1.5.6,!=1.5.7)"] test = ["PySocks (>=1.5.6,!=1.5.7)", "pytest (>=3)", "pytest-cov", "pytest-httpbin (==2.1.0)", "pytest-mock", "pytest-xdist"] use-chardet-on-py3 = ["chardet (>=3.0.2,<8)"] -[[package]] -name = "scipy" -version = "1.15.3" -description = "Fundamental algorithms for scientific computing in Python" -optional = false -python-versions = ">=3.10" -groups = ["main", "dev"] -files = [ - {file = "scipy-1.15.3-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:a345928c86d535060c9c2b25e71e87c39ab2f22fc96e9636bd74d1dbf9de448c"}, - {file = "scipy-1.15.3-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:ad3432cb0f9ed87477a8d97f03b763fd1d57709f1bbde3c9369b1dff5503b253"}, - {file = "scipy-1.15.3-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:aef683a9ae6eb00728a542b796f52a5477b78252edede72b8327a886ab63293f"}, - {file = "scipy-1.15.3-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:1c832e1bd78dea67d5c16f786681b28dd695a8cb1fb90af2e27580d3d0967e92"}, - {file = "scipy-1.15.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:263961f658ce2165bbd7b99fa5135195c3a12d9bef045345016b8b50c315cb82"}, - {file = "scipy-1.15.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e2abc762b0811e09a0d3258abee2d98e0c703eee49464ce0069590846f31d40"}, - {file = "scipy-1.15.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ed7284b21a7a0c8f1b6e5977ac05396c0d008b89e05498c8b7e8f4a1423bba0e"}, - {file = "scipy-1.15.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:5380741e53df2c566f4d234b100a484b420af85deb39ea35a1cc1be84ff53a5c"}, - {file = "scipy-1.15.3-cp310-cp310-win_amd64.whl", hash = "sha256:9d61e97b186a57350f6d6fd72640f9e99d5a4a2b8fbf4b9ee9a841eab327dc13"}, - {file = "scipy-1.15.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:993439ce220d25e3696d1b23b233dd010169b62f6456488567e830654ee37a6b"}, - {file = "scipy-1.15.3-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:34716e281f181a02341ddeaad584205bd2fd3c242063bd3423d61ac259ca7eba"}, - {file = "scipy-1.15.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:3b0334816afb8b91dab859281b1b9786934392aa3d527cd847e41bb6f45bee65"}, - {file = "scipy-1.15.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:6db907c7368e3092e24919b5e31c76998b0ce1684d51a90943cb0ed1b4ffd6c1"}, - {file = "scipy-1.15.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:721d6b4ef5dc82ca8968c25b111e307083d7ca9091bc38163fb89243e85e3889"}, - {file = "scipy-1.15.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39cb9c62e471b1bb3750066ecc3a3f3052b37751c7c3dfd0fd7e48900ed52982"}, - {file = "scipy-1.15.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:795c46999bae845966368a3c013e0e00947932d68e235702b5c3f6ea799aa8c9"}, - {file = "scipy-1.15.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:18aaacb735ab38b38db42cb01f6b92a2d0d4b6aabefeb07f02849e47f8fb3594"}, - {file = "scipy-1.15.3-cp311-cp311-win_amd64.whl", hash = "sha256:ae48a786a28412d744c62fd7816a4118ef97e5be0bee968ce8f0a2fba7acf3bb"}, - {file = "scipy-1.15.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:6ac6310fdbfb7aa6612408bd2f07295bcbd3fda00d2d702178434751fe48e019"}, - {file = "scipy-1.15.3-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:185cd3d6d05ca4b44a8f1595af87f9c372bb6acf9c808e99aa3e9aa03bd98cf6"}, - {file = "scipy-1.15.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:05dc6abcd105e1a29f95eada46d4a3f251743cfd7d3ae8ddb4088047f24ea477"}, - {file = "scipy-1.15.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:06efcba926324df1696931a57a176c80848ccd67ce6ad020c810736bfd58eb1c"}, - {file = "scipy-1.15.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c05045d8b9bfd807ee1b9f38761993297b10b245f012b11b13b91ba8945f7e45"}, - {file = "scipy-1.15.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:271e3713e645149ea5ea3e97b57fdab61ce61333f97cfae392c28ba786f9bb49"}, - {file = "scipy-1.15.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6cfd56fc1a8e53f6e89ba3a7a7251f7396412d655bca2aa5611c8ec9a6784a1e"}, - {file = "scipy-1.15.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0ff17c0bb1cb32952c09217d8d1eed9b53d1463e5f1dd6052c7857f83127d539"}, - {file = "scipy-1.15.3-cp312-cp312-win_amd64.whl", hash = "sha256:52092bc0472cfd17df49ff17e70624345efece4e1a12b23783a1ac59a1b728ed"}, - {file = "scipy-1.15.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2c620736bcc334782e24d173c0fdbb7590a0a436d2fdf39310a8902505008759"}, - {file = "scipy-1.15.3-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:7e11270a000969409d37ed399585ee530b9ef6aa99d50c019de4cb01e8e54e62"}, - {file = "scipy-1.15.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:8c9ed3ba2c8a2ce098163a9bdb26f891746d02136995df25227a20e71c396ebb"}, - {file = "scipy-1.15.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:0bdd905264c0c9cfa74a4772cdb2070171790381a5c4d312c973382fc6eaf730"}, - {file = "scipy-1.15.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79167bba085c31f38603e11a267d862957cbb3ce018d8b38f79ac043bc92d825"}, - {file = "scipy-1.15.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9deabd6d547aee2c9a81dee6cc96c6d7e9a9b1953f74850c179f91fdc729cb7"}, - {file = "scipy-1.15.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:dde4fc32993071ac0c7dd2d82569e544f0bdaff66269cb475e0f369adad13f11"}, - {file = "scipy-1.15.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f77f853d584e72e874d87357ad70f44b437331507d1c311457bed8ed2b956126"}, - {file = "scipy-1.15.3-cp313-cp313-win_amd64.whl", hash = "sha256:b90ab29d0c37ec9bf55424c064312930ca5f4bde15ee8619ee44e69319aab163"}, - {file = "scipy-1.15.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:3ac07623267feb3ae308487c260ac684b32ea35fd81e12845039952f558047b8"}, - {file = "scipy-1.15.3-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:6487aa99c2a3d509a5227d9a5e889ff05830a06b2ce08ec30df6d79db5fcd5c5"}, - {file = "scipy-1.15.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:50f9e62461c95d933d5c5ef4a1f2ebf9a2b4e83b0db374cb3f1de104d935922e"}, - {file = "scipy-1.15.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:14ed70039d182f411ffc74789a16df3835e05dc469b898233a245cdfd7f162cb"}, - {file = "scipy-1.15.3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a769105537aa07a69468a0eefcd121be52006db61cdd8cac8a0e68980bbb723"}, - {file = "scipy-1.15.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9db984639887e3dffb3928d118145ffe40eff2fa40cb241a306ec57c219ebbbb"}, - {file = "scipy-1.15.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:40e54d5c7e7ebf1aa596c374c49fa3135f04648a0caabcb66c52884b943f02b4"}, - {file = "scipy-1.15.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:5e721fed53187e71d0ccf382b6bf977644c533e506c4d33c3fb24de89f5c3ed5"}, - {file = "scipy-1.15.3-cp313-cp313t-win_amd64.whl", hash = "sha256:76ad1fb5f8752eabf0fa02e4cc0336b4e8f021e2d5f061ed37d6d264db35e3ca"}, - {file = "scipy-1.15.3.tar.gz", hash = "sha256:eae3cf522bc7df64b42cad3925c876e1b0b6c35c1337c93e12c0f366f55b0eaf"}, -] - -[package.dependencies] -numpy = ">=1.23.5,<2.5" - -[package.extras] -dev = ["cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy (==1.10.0)", "pycodestyle", "pydevtool", "rich-click", "ruff (>=0.0.292)", "types-psutil", "typing_extensions"] -doc = ["intersphinx_registry", "jupyterlite-pyodide-kernel", "jupyterlite-sphinx (>=0.19.1)", "jupytext", "matplotlib (>=3.5)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (>=0.15.2)", "sphinx (>=5.0.0,<8.0.0)", "sphinx-copybutton", "sphinx-design (>=0.4.0)"] -test = ["Cython", "array-api-strict (>=2.0,<2.1.1)", "asv", "gmpy2", "hypothesis (>=6.30)", "meson", "mpmath", "ninja ; sys_platform != \"emscripten\"", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] - [[package]] name = "six" version = "1.17.0" @@ -2411,4 +2347,4 @@ plot = ["matplotlib"] [metadata] lock-version = "2.1" python-versions = ">=3.10" -content-hash = "6fa1a339c4fcc01313aa6efe721d81200d3437116042cbe47fbb34b42415ba65" +content-hash = "b823eead3c4ccf362bc847ce2852507a156d1f7ad404fdbfa4800c1abfd04761" diff --git a/pyproject.toml b/pyproject.toml index 011943ca..2ad1a458 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ include = ["py.typed", "*.pyx"] [tool.poetry.dependencies] python = ">=3.10" numpy = ">=1.23.5" -scipy = ">=1.10.0" matplotlib = { version = ">=3.0", optional = true } sphinx = { version = "==8.1.3", optional = true } sphinx-autodoc-typehints = { version = "*", optional = true } @@ -48,7 +47,6 @@ sphinx-rtd-theme = { version = "*", optional = true } [tool.poetry.group.dev.dependencies] numpy = "==2.2.6" -scipy = "==1.15.3" matplotlib = "==3.10.9" [tool.poetry.group.test.dependencies]