arkouda.history

Classes

HistoryRetriever

Abstract base class that defines the retrieve method signature.

NotebookHistoryRetriever

Implement the retrieve method to get command history from a Jupyter notebook or IPython shell.

ShellHistoryRetriever

Implement the retrieve method to get command history from the Python REPL shell.

Module Contents

class arkouda.history.HistoryRetriever[source]

Abstract base class that defines the retrieve method signature.

Implements _filter_arkouda_command.

abstractmethod retrieve(command_filter: str | None = None, num_commands: int | None = None) List[str][source]

Generate list of commands executed.

Generate list of commands executed within a Python REPL shell, Jupyter notebook, or IPython notebook, with an optional command filter and number of commands to return.

Parameters:
  • num_commands (int) – The number of commands from history to retrieve

  • command_filter (str) – String containing characters used to select a subset of command history.

  • noqa (Returns #)

  • -------

  • List[str] – A list of commands from the Python shell, Jupyter notebook, or IPython notebook

class arkouda.history.NotebookHistoryRetriever(profile: str = 'default', hist_file: str = '', **traits: Any)[source]

Bases: IPython.core.history.HistoryAccessor, HistoryRetriever

Implement the retrieve method to get command history from a Jupyter notebook or IPython shell.

retrieve(command_filter: str | None = None, num_commands: int | None = None) List[str][source]

Generate list of commands executed.

Generate list of commands executed within a Jupyter notebook or IPython shell, with an optional command filter and number of commands to return.

Parameters:
  • num_commands (int) – The number of commands from history to retrieve

  • command_filter (str) – String containing characters used to select a subset of command history.

Returns:

A list of commands from the Python shell, Jupyter notebook, or IPython notebook

Return type:

List[str]

Examples

>>> import arkouda as ak
>>> from arkouda.history import NotebookHistoryRetriever
>>> h = NotebookHistoryRetriever()
>>> 1+2
>>> 4*6
>>> 2**3
>>> h.retrieve(num_commands=3)
['1+2', '4*6', '2**3']
class arkouda.history.ShellHistoryRetriever[source]

Bases: HistoryRetriever

Implement the retrieve method to get command history from the Python REPL shell.

retrieve(command_filter: str | None = None, num_commands: int | None = None) List[str][source]

Generate list of commands executed.

Generate list of commands executed within the a Python REPL shell, with an optional command filter and number of commands to return.

Parameters:
  • num_commands (int) – The number of commands from history to retrieve

  • command_filter (str) – String containing characters used to select a subset of command history.

Returns:

A list of commands from the Python shell, Jupyter notebook, or IPython notebook

Return type:

List[str]

Examples

>>> import arkouda as ak
>>> from arkouda.history import ShellHistoryRetriever
>>> import readline
>>> h = ShellHistoryRetriever()
>>> readline.clear_history()
>>> 1 + 2
3
>>> h.retrieve()
[' 1 + 2', 'h.retrieve()']