Skip to content

Commit

Permalink
Add duecredit citation.
Browse files Browse the repository at this point in the history
This is a low-cost way to give credit to the relevant publications. This will
only express itself, if the user runs it with duecredit. But when that happens,
we'll be ready!
  • Loading branch information
arokem committed Apr 19, 2016
1 parent 8ad153d commit 8dd25dd
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
65 changes: 65 additions & 0 deletions shablona/due.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit is
not available.
To use it, just place it into your project codebase to be imported, e.g. copy as
cp stub.py /path/tomodule/module/due.py
Note that it might be better to avoid naming it duecredit.py to avoid shadowing
installed duecredit.
Then use in your code as
from .due import due, Doi, BibTeX
Examples
--------
TODO
License:
Originally a part of the duecredit, which is distributed under BSD-2 license.
"""

__version__ = '0.0.4'

class InactiveDueCreditCollector(object):
"""Just a stub at the Collector which would not do anything"""
def _donothing(self, *args, **kwargs):
"""Perform no good and no bad"""
pass

def dcite(self, *args, **kwargs):
"""If I could cite I would"""
def nondecorating_decorator(func):
return func
return nondecorating_decorator

cite = load = add = _donothing

def __repr__(self):
return self.__class__.__name__ + '()'

def _donothing_func(*args, **kwargs):
"""Perform no good and no bad"""
pass

try:
from duecredit import *
if 'due' in locals() and not hasattr(due, 'cite'):
raise RuntimeError("Imported due lacks .cite. DueCredit is now disabled")
except Exception as e:
if type(e).__name__ != 'ImportError':
import logging
logging.getLogger("duecredit").error(
"Failed to import duecredit due to %s" % str(e))
# Initiate due stub
due = InactiveDueCreditCollector()
BibTeX = Doi = Url = _donothing_func
6 changes: 6 additions & 0 deletions shablona/shablona.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
import pandas as pd
import scipy.optimize as opt
from scipy.special import erf
from .due import due, Doi, BibTeX

__all__ = ["Model", "Fit", "opt_err_func", "transform_data", "cumgauss"]


# Use duecredit (duecredit.org) to provide a citation to relevant work to
# be cited. This does nothing, unless the user has duecredit installted,
# And calls this with duecredit (as in `python -m duecredit script.py`):
due.cite(Doi("10.1167/13.9.30"))

def transform_data(data):
"""
Function that takes experimental data and gives us the
Expand Down

0 comments on commit 8dd25dd

Please sign in to comment.