Skip to content

Commit

Permalink
Merge pull request hyperspy#3302 from jlaehne/hidden-signal
Browse files Browse the repository at this point in the history
Allow hiding signals provided by extensions
  • Loading branch information
ericpre authored Oct 19, 2024
2 parents 87b61b6 + 7354f6b commit 8bc57e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/dev_guide/writing_extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ the signal subclass with ``Electron Energy Loss Spectroscopy`` signal type.
It is good practice to choose a very explicit ``signal_type`` while leaving
acronyms for ``signal_type_aliases``.

Additionally, the optional key ``hidden: True`` can be defined if a signal should
be registered with HyperSpy, but not listed by :meth:`hyperspy.api.print_known_signal_types`.
This option can be used if a signal subclass is needed for certain functionalities,
such as casting to a different signal subclass, but should usually not be set
directly by the user.

Creating new HyperSpy model components
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion hyperspy/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def print_known_signal_types(style=None):
table.set_style(style)
for sclass, sdict in ALL_EXTENSIONS["signals"].items():
# skip lazy signals and non-data-type specific signals
if sdict["lazy"] or not sdict["signal_type"]:
if sdict["lazy"] or sdict.get("hidden", False) or not sdict["signal_type"]:
continue
aliases = (
", ".join(sdict["signal_type_aliases"])
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/3302.enhancements.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow setting optional ``hidden`` key in definition of signals extending hyperspy, which prevents them from being shown by ``print_known_signal_types()``.

0 comments on commit 8bc57e1

Please sign in to comment.