pyrolite.util.meta

pyrolite.util.meta.get_module_datafolder(module='pyrolite', subfolder=None)[source]

Returns the path of a module data folder.

Parameters

subfolder (str) – Subfolder within the module data folder.

Return type

pathlib.Path

pyrolite.util.meta.pyrolite_datafolder(subfolder=None)[source]

Returns the path of the pyrolite data folder.

Parameters

subfolder (str) – Subfolder within the pyrolite data folder.

Return type

pathlib.Path

pyrolite.util.meta.take_me_to_the_docs()[source]

Opens the pyrolite documentation in a webbrowser.

Generate a string with a restructured text link to a given DOI.

Parameters

doi (str)

Returns

String with doi link.

Return type

str

pyrolite.util.meta.subkwargs(kwargs, *f)[source]

Get a subset of keyword arguments which are accepted by a function.

Parameters
  • kwargs (dict) – Dictionary of keyword arguments.

  • f (callable) – Function(s) to check.

Returns

Dictionary containing only relevant keyword arguments.

Return type

dict

pyrolite.util.meta.inargs(name, *funcs)[source]

Check if an argument is a possible input for a specific function.

Parameters
  • name (str) – Argument name.

  • f (callable) – Function(s) to check.

Return type

bool

pyrolite.util.meta.numpydoc_str_param_list(iterable, indent=4)[source]

Format a list of numpydoc parameters.

Parameters
  • iterable (list) – List of numpydoc parameters.

  • indent (int) – Indent as number of spaces.

Return type

str

pyrolite.util.meta.get_additional_params(*fs, t='Parameters', header='', indent=4, subsections=False, subsection_delim='Note')[source]

Checks the base Parameters section of docstrings to get ‘Other Parameters’ for a specific function. Designed to incorporate information on inherited or forwarded parameters.

Parameters
  • fs (list) – List of functions.

  • t (str) – Target block of docstrings.

  • header (str) – Optional seciton header.

  • indent (int | str) – Indent as number of spaces, or a string of a given length.

  • subsections (bool, False) – Whether to include headers specific for each function, creating subsections.

  • subsection_delim (str) – Subsection delimiter.

Return type

str

Todo

  • Add delimiters between functions to show where arguments should be passed.

pyrolite.util.meta.update_docstring_references(obj, ref='ref')[source]

Updates docstring reference names to strings including the function name. Decorator will return the same function with a modified docstring. Sphinx likes unique names - specifically for citations, not so much for footnotes.

Parameters
  • obj (func | class) – Class or function for which to update documentation references.

  • ref (str) – String to replace with the object name.

Returns

Object with modified docstring.

Return type

func | class