Skip to content

Commit

Permalink
Merge pull request #2 from yarikoptic/pr-29
Browse files Browse the repository at this point in the history
BF: made due.py PEP8 compliant and harmonized some indentations in README.md
  • Loading branch information
arokem committed Apr 19, 2016
2 parents 8dd25dd + 9308728 commit ceae111
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 48 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ share it with others, test it, document it, and track its evolution.

The project has the following structure:

shablona -
|- `README.md`
|- shablona
|- `__init__.py`
|- `shablona.py`
|- data
|- ...
|- tests
|- ...
|- doc
|- `Makefile`
|- `conf.py`
|- sphinxext
|- ...
|- _static
|- ...
|- `setup.py`
|- `.travis.yml`
|- `appveyor.yml`
|- `LICENSE`
|- ipynb
|- ...
shablona/
|- README.md
|- shablona/
|- __init__.py
|- shablona.py
|- data/
|- ...
|- tests/
|- ...
|- doc/
|- Makefile
|- conf.py
|- sphinxext/
|- ...
|- _static/
|- ...
|- setup.py
|- .travis.yml
|- appveyor.yml
|- LICENSE
|- ipynb/
|- ...


In the following sections we will examine these elements one by one. First,
Expand Down Expand Up @@ -84,8 +84,8 @@ In this case, the project data is rather small, and recorded in csv files. Thus,
Either way, you can create a `shablona/data` folder in which you can organize the data. As you can see in the test scripts, and in the analysis scripts, this provides a standard file-system location for the data at:

import os.path as op
import shablona as sb
data_path = op.join(sb.__path__[0], 'data')
import shablona as sb
data_path = op.join(sb.__path__[0], 'data')


### Testing
Expand Down Expand Up @@ -335,7 +335,7 @@ To use this repository as a template, start by cloning it to your own computer u

To point to your own repository on github you will have to issue something like the following:

git remote rm origin
git remote rm origin
git remote add origin https://github.com/arokem/smallish

(replace `arokem` with your own Github user name).
Expand Down
2 changes: 1 addition & 1 deletion shablona/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .shablona import * # noqa
from .version import __version__ # noqa
from .shablona import * # noqa
45 changes: 26 additions & 19 deletions shablona/due.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit is
not available.
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
To use it, place it into your project codebase to be imported, e.g. copy as
cp stub.py /path/tomodule/module/due.py
Expand All @@ -17,18 +17,15 @@
from .due import due, Doi, BibTeX
See https://github.com/duecredit/duecredit/blob/master/README.md for examples.
Examples
--------
TODO
License:
Originally a part of the duecredit, which is distributed under BSD-2 license.
Origin: Originally a part of the duecredit
Copyright: 2015-2016 DueCredit developers
License: BSD-2
"""

__version__ = '0.0.4'
__version__ = '0.0.5'


class InactiveDueCreditCollector(object):
"""Just a stub at the Collector which would not do anything"""
Expand All @@ -39,22 +36,24 @@ def _donothing(self, *args, **kwargs):
def dcite(self, *args, **kwargs):
"""If I could cite I would"""
def nondecorating_decorator(func):
return func
return func
return nondecorating_decorator

cite = load = add = _donothing
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 *
from duecredit import due, BibTeX, Doi, Url
if 'due' in locals() and not hasattr(due, 'cite'):
raise RuntimeError("Imported due lacks .cite. DueCredit is now disabled")
raise RuntimeError(
"Imported due lacks .cite. DueCredit is now disabled")
except Exception as e:
if type(e).__name__ != 'ImportError':
import logging
Expand All @@ -63,3 +62,11 @@ def _donothing_func(*args, **kwargs):
# Initiate due stub
due = InactiveDueCreditCollector()
BibTeX = Doi = Url = _donothing_func

# Emacs mode definitions
# Local Variables:
# mode: python
# py-indent-offset: 4
# tab-width: 4
# indent-tabs-mode: nil
# End:
10 changes: 7 additions & 3 deletions shablona/shablona.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
import pandas as pd
import scipy.optimize as opt
from scipy.special import erf
from .due import due, Doi, BibTeX
from .due import due, Doi

__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,
# be cited. This does nothing, unless the user has duecredit installed,
# And calls this with duecredit (as in `python -m duecredit script.py`):
due.cite(Doi("10.1167/13.9.30"))
due.cite(Doi("10.1167/13.9.30"),
description="Template project for small scientific Python projects",
tags=["reference-implementation"],
path='shablona')


def transform_data(data):
"""
Expand Down

0 comments on commit ceae111

Please sign in to comment.