diff --git a/CHANGES.rst b/CHANGES.rst index 57b5386cfe..7bc87e59e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,8 @@ RELEASE_next_patch (Unreleased) * Pass keyword argument to the image IO plugins (`#2627 `_) * Drop support for numpy<1.16, in line with NEP 29 and fix protochip reader for numpy 1.20 (`#2616 `_) * Run test suite against upstream dependencies (numpy, scipy, scikit-learn and scikit-image) (`#2616 `_) +* Improve error message when file not found (`#2597 `_) +* Add update instructions to user guide (`#2621 `_) * Improve error message when initialising SpanROI with left >= right (`#2604 `_) diff --git a/doc/user_guide/install.rst b/doc/user_guide/install.rst index 3cc010fe33..089597fb1c 100644 --- a/doc/user_guide/install.rst +++ b/doc/user_guide/install.rst @@ -33,7 +33,8 @@ read the :ref:`conda installation ` and HyperSpy Bundle --------------- -The HyperSpy bundle is very similar to the Anaconda distribution, and it includes: +The `HyperSpy `_ bundle is very similar +to the Anaconda distribution, and it includes: * HyperSpy * HyperSpyUI @@ -48,15 +49,16 @@ Portable distribution (Windows only) A portable version of the `HyperSpy bundle `_ based on the WinPython distribution is also available on Windows. - .. _anaconda-install: -Installation in an Anaconda/Miniconda distribution --------------------------------------------------- +Installation using conda +------------------------ -HyperSpy is packaged in the `conda-forge `_ channel -and can be installed easily using the `conda `_ -package manager. +`Conda `_ is a package manager for Anaconda-like +distributions, such as the `Miniforge `_ +or the `HyperSpy-bundle `_. +Since HyperSpy is packaged in the `conda-forge `_ channel, +it can easily be installed using conda. To install hyperspy run the following from the Anaconda Prompt on Windows or from a Terminal on Linux and Mac. @@ -132,6 +134,7 @@ To learn more about the Anaconda eco-system: - Choose between `Anaconda or Miniconda `_? - Understanding `conda and pip `_. +- What is `conda-forge `_. .. _install-with-pip: @@ -145,16 +148,16 @@ install pip for the following commands to run. To install all hyperspy functionalities, run: -.. code-block:: bash + .. code-block:: bash - $ pip install hyperspy[all] + $ pip install hyperspy[all] To install only the strictly required dependencies and limited functionalities, use: -.. code-block:: bash + .. code-block:: bash - $ pip install hyperspy + $ pip install hyperspy See the following list of selectors to select the installation of optional dependencies required by specific functionalities: @@ -184,6 +187,51 @@ tools installed in the system. If the above does not work for you remember that the easiest way to install HyperSpy is :ref:`using the HyperSpy bundle `. +.. _update-with-conda: + +Update HyperSpy +--------------- + +Using conda +^^^^^^^^^^^ + +To update hyperspy to the latest release using conda: + + .. code-block:: bash + + $ conda update hyperspy -c conda-forge + +Using pip +^^^^^^^^^ + +To update hyperspy to the latest release using pip: + + .. code-block:: bash + + $ pip install hyperspy --upgrade + +Install specific version +------------------------ + +Using conda +^^^^^^^^^^^ + +To install a specific version of hyperspy (for example ``1.6.1``) using conda: + + .. code-block:: bash + + $ conda install hyperspy=1.6.1 -c conda-forge + +Using pip +^^^^^^^^^ + +To install a specific version of hyperspy (for example ``1.6.1``) using pip: + + .. code-block:: bash + + $ pip install hyperspy==1.6.1 + + .. _install-dev: Rolling release Linux distributions @@ -196,11 +244,11 @@ or :ref:`Pip ` is recommended. However, packages of the latest HyperSpy release and the related GUI packages are maintained for the rolling release distributions -**Arch-Linux** (in the `Arch User Repository +*Arch-Linux* (in the `Arch User Repository `_) (AUR) and -**openSUSE** (`Community Package `_) -as ``python-hyperspy`` and ``python-hyperspy-gui-traitsui`` / -``python-hyperspy-gui-ipywidgets``. +*openSUSE* (`Community Package `_) +as ``python-hyperspy`` and ``python-hyperspy-gui-traitsui``, +``python-hyperspy-gui-ipywidgets`` for the GUIs packages. A more up-to-date package that contains all updates to be included in the next minor version release (likely including new features compared to diff --git a/hyperspy/io.py b/hyperspy/io.py index ea0b532f52..078c071865 100644 --- a/hyperspy/io.py +++ b/hyperspy/io.py @@ -314,6 +314,7 @@ def load(filenames=None, raise ValueError("No file provided to reader") if isinstance(filenames, str): + pattern = filenames if escape_square_brackets: filenames = _escape_square_brackets(filenames) @@ -321,7 +322,7 @@ def load(filenames=None, if os.path.isfile(f)]) if not filenames: - raise ValueError('No filename matches this pattern') + raise ValueError(f'No filename matches the pattern "{pattern}"') elif isinstance(filenames, Path): # Just convert to list for now, pathlib.Path not diff --git a/hyperspy/tests/io/test_io.py b/hyperspy/tests/io/test_io.py index 2834ec4b52..af031aaecc 100644 --- a/hyperspy/tests/io/test_io.py +++ b/hyperspy/tests/io/test_io.py @@ -98,7 +98,7 @@ def test_glob_wildcards(): for f in fnames: s.save(f) - with pytest.raises(ValueError, match="No filename matches this pattern"): + with pytest.raises(ValueError, match="No filename matches the pattern"): _ = hs.load(fnames[0]) t = hs.load([fnames[0]]) @@ -113,7 +113,7 @@ def test_glob_wildcards(): t = hs.load(os.path.join(dirpath, "temp[*].hspy"), escape_square_brackets=True,) assert len(t) == 2 - with pytest.raises(ValueError, match="No filename matches this pattern"): + with pytest.raises(ValueError, match="No filename matches the pattern"): _ = hs.load(os.path.join(dirpath, "temp[*].hspy")) # Test pathlib.Path @@ -137,7 +137,7 @@ def test_file_not_found_error(): if os.path.exists(temp_fname): os.remove(temp_fname) - with pytest.raises(ValueError, match="No filename matches this pattern"): + with pytest.raises(ValueError, match='No filename matches the pattern'): _ = hs.load(temp_fname) with pytest.raises(FileNotFoundError):