Skip to content

API reference

The main entry point is the Authors class, documented below.

authors.Authors class

authors.Authors(load_from, warn_unknown=True)

Hold information about the authors of a paper

Parameters:

Name Type Description Default
load_from str

From where to load the author list. Can be a '\n'-separated string with the author names or the name of a file containing the list of authors.

required
warn_unknown bool

Whether to emit warninings for unknown authors

True

Examples:

>>> Authors('First Name\nSecond Name')
>>> Authors('author_list.txt')

AandA(show=True, add_orcids=True, preview=False, alphabetical=False, alphabetical_after=1, alphabetical_groups=None, add_email=True, force_initials=True, save_to_file=None)

Provide the \author and \institute LaTeX tags for A&A

Parameters:

Name Type Description Default
show bool

Whether to print the \author and \institute tags (otherwise just return them in a string).

True
add_orcids bool

Whether to add ORCID links for authors that have them. Note that this may require additional LaTeX, and may not be accepted by every journal.

True
preview bool

Try to compile and preview a template LaTeX file.

False
alphabetical bool

Whether to sort author (last) names alphabetically.

False
alphabetical_after int

Sort author names alphabetically after this author. By default, sort after the first author.

1
alphabetical_groups List[int]

If provided, sort author names alphabetically in groups. Examples: [5, 10] authors 1, 2, 3, 4, 5 use order as given authors 6, 7, 8, 9, 10 sorted alphabetically authors 11, ... sorted alphabetically [3] authors 1, 2, 3 use order as given authors 4, ... sorted alphabetically (this would be equivalent to using alphabetical_after=3)

None
add_email bool

Add email address for first author (if available)

True
force_initials bool

If True, force the author names to be F. M. Last

True
save_to_file str

File where to save the LaTeX tags

None
copy_to_clipboard bool

Copy the LaTeX tags to the clipboard

required

MNRAS(show=True, preview=False, line_breaks=6, alphabetical=False, alphabetical_after=1, alphabetical_groups=None, force_initials=True, save_to_file=None)

Provide the \author LaTeX tag for MNRAS

Parameters:

Name Type Description Default
show bool

Whether to print the LaTeX tags (otherwise, just return them)

True
preview bool

NO DOC

False
add_orcids bool

NO DOC

required
alphabetical bool

Whether to sort author names alphabetically. Default is False

False
alphabetical_after int

Sort author names alphabetically after this author. By default, sort after the first author.

1
alphabetical_groups List[int]

If provided, sort author names alphabetically in groups. Examples: [5, 10] authors 1, 2, 3, 4, 5 use order as given authors 6, 7, 8, 9, 10 sorted alphabetically authors 11, ... sorted alphabetically [3] authors 1, 2, 3 use order as given authors 4, ... sorted alphabetically (this would be equivalent to using alphabetical_after=3)

None
force_initials bool

If True, force the author names to be F. M. Last

True
save_to_file str

File where to save the LaTeX tags

None
copy_to_clipboard bool

Copy the LaTeX tags to the clipboard

required

Inside the authors package, there are a few other useful modules:

authors module

authors.authors

Names(names, nicknames=[], warnings=False)

Holds a list of names and implements the in operator

Parameters:

Name Type Description Default
names List[str]

List of names

required
nicknames List[str]

List of nicknames.

[]
warnings bool

Whether to print warnings for duplicate names.

False

change_affiliation(old, new)

Change an affiliation

Parameters:

Name Type Description Default
old str

old affiliation, which will be replaced

required
new str

new affiliation

required

delete_author(name)

Remove an author from the known author list

Parameters:

Name Type Description Default
name str

name of the author to remove

required

get_all_affiliations()

Get a list of all known affiliations

get_all_affiliations_with_label()

Get a dictionary of all known affiliations that have a label

get_all_known_authors(return_filename=False)

Load the dictionary of all known authors

Parameters:

Name Type Description Default
return_filename bool

Whether to return the path to the yaml file

False

Returns:

Name Type Description
known_authors dict

Dictionary with information about the known authors

file str

Only returned if return_filename is True. Path to the yaml file

register_author(full_name, affiliations, labels=None, email=None, orcid=None, acknowledgements=None, nickname=None, spelling=None)

Register a new author

Parameters:

Name Type Description Default
full_name str

Full name of the author

required
affiliations List[str]

List of affiliations

required
labels List[str]

Labels to use for each affiliation. Should have the same length as affiliations.

None
email str

Email address.

None
orcid str

ORCID id.

None
acknowledgements str

Author's acknowledgements.

None
nickname str

Nickname of the author.

None
spelling str

Exact spelling of the author's name.

None

set_affiliation_label(affiliation, label)

Set the label for a given affiliation

Parameters:

Name Type Description Default
affiliation str

the affiliation to set the label for

required
label str

the label

required

update_author_acknowledgements(name, acknowledgements)

Update the acknowledgements of an author

Parameters:

Name Type Description Default
name str

The name of the author

required
acknowledgements str

The new acknowledgements

required

update_author_affiliations(name, affiliations, strategy='merge')

Update the affiliations of an author

Parameters:

Name Type Description Default
name str

The name of the author

required
affiliations List[str]

List of new affiliations

required
strategy Literal['merge', 'replace']

Which strategy to use for the update. If 'merge', the new affiliations are added to the existing ones (keeping only unique). If 'replace', the existing affiliations are replaced.

'merge'

update_author_email(name, email, allow_closest=False)

Update the email of an author

Parameters:

Name Type Description Default
name str

The name of the author

required
email str

The new email address

required
allow_closest bool

If True and name is not found, try to find the closest match in the list of known authors

False

update_author_name(old_name, new_name, allow_closest=False)

Update the name of one author

Parameters:

Name Type Description Default
old_name str

The old name, which should exist in the list of known authors

required
new_name str

The new name of the author

required
allow_closest bool

If True and old_name is not found, try to find the closest match in the list of known authors

False

update_author_nickname(name, nickname)

Update the nickname of an author

Parameters:

Name Type Description Default
name str

The name of the author

required
nickname str

The new nickname

required

update_author_orcid(name, orcid, allow_closest=False)

Update the ORCID of an author

Parameters:

Name Type Description Default
name str

The name of the author

required
orcid str

The new ORCID

required
allow_closest bool

If True and name is not found, try to find the closest match in the list of known authors

False

update_author_spelling(name, spelling)

Update the spelling of an author's name

Parameters:

Name Type Description Default
name str

The name of the author

required
spelling str

The new spelling

required

write_all_known_authors(data, confirm=True)

Write all the known authors to the yaml file

Parameters:

Name Type Description Default
data dict

Dictionary with information about the known authors

required
confirm bool

Whether to ask for confirmation before overwriting the YAML file

True

Raises:

Type Description
ValueError

If data is empty

Warning

This function overwrites the local YAML file that contains the author database. Use with caution!

utils module

authors.utils

bitapSearch(haystack, needle, maxErrors)

Bitap (Shift-Or) fuzzy searching algorithm with Wu-Manber modifications. http://habrahabr.ru/post/114997/ http://habrahabr.ru/post/132128/ http://ru.wikipedia.org/wiki/Двоичный_алгоритм_поиска_подстроки

Search needle(pattern) in haystack(real word from text) with maximum alterations = maxErrors. If maxErrors equal 0 - execute precise searching only.

Return approximately place of needle in haystack and number of alterations. If needle can't find with maxErrors alterations, return tuple of empty string and -1.

lev_dist(a, b)

Calculates the Levenshtein distance between two input strings a and b

Parameters:

Name Type Description Default
a,b str)

The two strings to be compared

required

Returns:

Type Description
float

The Levenshtein distance between string a and b.

Examples:

>>> lev_dist('stamp', 'stomp')
1.0

tex_deescape(text)

De-escape text from TeX characters

tex_escape(text)

Escape text so it appears correctly in LaTeX