When importing the PyMICE library, you are prompted to reference it in any published research.
import pymice as pm
Citation
class¶To facilitate the referencing, the library provides a class Citation
. The class may be especially useful in publications/reports written according to the Literate Programming paradigm (e.g. with Pweave tool).
Objects of the class may be converted both to unicode
and str
(UTF-8 encoded) strings which are the recommended in-text reference of the library.
citation = pm.Citation()
print unicode(citation)
print str(citation)
As you may see, the current version of the library has been referenced.
The citation
object provides also items to be included in the Bibliography section as its attributes.
print citation.PAPER
print
print citation.SOFTWARE
To cite PyMICE not in the suggested format you may use .CITE_PAPER
and .CITE_SOFTWARE
properties.
print citation.CITE_PAPER
print
print citation.CITE_SOFTWARE
With the new style of Python string formatting (.format()
), the object may be easily used to automatically generate the reference.
PUBLICATION_TEMPLATE = u"""With the new Python string formatting API (.format()), the object may be easily used to automatically generate the reference.
Methods
The following tutorial has been executed with {reference}.
Bibliography
{reference.PAPER}
{reference.SOFTWARE}
"""
print PUBLICATION_TEMPLATE.format(reference=pm.Citation())
Citation
object¶Sometimes it is necessary to comply with a certain reference style (like Vancouver or APA6). Objects of the Citation
class may be easily customised to fit such needs.
PUBLICATION_TEMPLATE = u"""\n\n{reference} facilitates referencing in {style} style.
Bibliography:
{reference.PAPER}
{reference.SOFTWARE}\n"""
for style in ['Vancouver', 'APA6']:
print PUBLICATION_TEMPLATE.format(style=style,
reference=pm.Citation(style=style))
As most publications is written with some markup system, the Citation
class supports different markups as well.
for name, symbol in [('Plain', 'txt'),
('Markdown', 'md'),
('reStructuredText', 'rst'),
('HTML', 'html'),
('LaTeX', 'latex'),]:
print '{} ({})'.format(name, symbol)
print
print pm.Citation(style='APA6', markdown=symbol).PAPER
print
print
The Citation
class supports also export of BibTeX entries.
print pm.Citation(style='BibTeX').SOFTWARE
In some cases (e.g. in case of BibTeX, LaTeX or Vancouver style) "keys" automatically assigned to bibliography items may be improper. The Citation
class provides mechanism to assign custom "keys" to the items.
PUBLICATION_TEMPLATE = u"""[...]
{reference} was used to run this tutorial.
[...]
Bibliography:
[...]
{reference.PAPER}
[...]
{reference.SOFTWARE}
[...]"""
print PUBLICATION_TEMPLATE.format(reference=pm.Citation(style='Vancouver',
paperKey='42',
softwareKey='44'))
Sometimes it may be necessary to reference another version of PyMICE than currently used. The version
parameter of the Citation
class enables referencing a custom version.
PUBLICATION_TEMPLATE = u"""Our publication introducing the PyMICE library ({reference.CITE_PAPER}) has been compiled with PyMICE v. {version} ({reference.CITE_SOFTWARE})
Bibliography:
{reference.PAPER}
{reference.SOFTWARE}
"""
print PUBLICATION_TEMPLATE.format(version='1.1.0',
reference=pm.Citation(version='1.1.0'))
If you need to generate a reference using different style, PyMICE version or markdown than set in the object constructor, you do not have to create a new object. A call to the methods: .cite()
, .citePaper()
, .citeSoftware()
, .referencePaper()
or .referenceSoftware()
with optional parameters style
, markdown
and version
returns a customised reference.
reference = pm.Citation()
print reference.cite(version='0.2.3')
print
print reference.citePaper(markdown='LaTeX')
print
print reference.citeSoftware(style='APA6')
print
print reference.referencePaper(style='Vancouver', markdown='HTML')
print
print reference.referenceSoftware(style='BibTeX', version='1.0.0')