Skip to content

Commit

Permalink
Merge pull request #40 from clbarnes/master
Browse files Browse the repository at this point in the history
Re-enable tests, readability improvements, fix transitivity bug
  • Loading branch information
aestrivex committed May 15, 2016
2 parents bb72ae4 + 96856ae commit 24df43b
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 96 deletions.
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
language: python

sudo : false

python:
- "2.7"
- "3.5"

# command to set up conda
before_install:
- if [ ${TRAVIS_PYTHON_VERSION:O:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda2-3.19.0-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.19.0-Linux-x86_64.sh -O miniconda.sh; fi
- bash miniconda.sh -b -p /home/travis/mc
- export PATH=/home/travis/mc/bin:$PATH

# command to install dependencies
install:
- conda update --yes conda
#- conda config --add channels soft-matter
- conda create -n testenv --yes numpy=1.10 scipy=0.17 nose setuptools python=${TRAVIS_PYTHON_VERSION}
- source activate testenv
- python setup.py install

before_install:
- if [ ${TRAVIS_PYTHON_VERSION:O:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda2-3.19.0-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.19.0-Linux-x86_64.sh -O miniconda.sh; fi
#- chmod +x miniconda.sh
- echo "red phones"
- bash miniconda.sh -b -p /home/travis/mc
- export PATH=/home/travis/mc/bin:$PATH
# command to run tests
script:
- nosetests -V
- nosetests --ignore-files="very_long_tests" -v
48 changes: 0 additions & 48 deletions CHANGELOG

This file was deleted.

46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# BCT 0.4.1

- Refactor code into multiple files
- Fix bug in efficiency_bin
- Fix bugs in modularity_louvain_und
- Fix bugs in `participation_coef_b*`
- Add some test cases

# BCT 0.4.0

- Add various new functions from Jan 2015 release of BCT
- Fix various bugs documented in github issues

# BCT 0.3.3

- Fix small bug in `latmio_und_connected` causing failure for sparse matrices
- Add non-networkx dependent algorithm to get_components (but less efficient)
- Add an implementation of consensus clustering and fix bug in agreement
- Fix bug causing `clustering_coef_bu` to always return 0
- Remembered to update changelog
- Fix some bugs in `modularity_louvain_dir` and related
- Fix bug in NBS and add optional paired-sample test statistic (sviter)

# BCT 0.3.2

- Change several functions including threshold_proportional and binarize have `copy=True` as default argument
- Fix bug in `threshold_proportional` where copying behavior did not work symmetric matrices.
- Fix minor quirk in `threshold_proportional` where `np.round` rounds to nearest even number (optimizes floating point) which is discrepant with BCT
- Add a test suite with some functions
- Fix typo in `rich_club_bu`
- Refactor `x[range(n),range(n)]` to `np.fill_diagonal`
- Fix off-by-one bug in `moduality_[prob/fine]tune_und_sign`

# BCT 0.3.1

- Fix bug in NBS
- Fix series of bugs in `null_models`

# BCT 0.3

- Added NBS
- Added in all of the new functions from the Dec 2013 release of BCT
- Fixed numerous bugs having to do with indexing errors in modularity
- Fixed several odd bugs with `clustering_coef`, `efficiency`, `distance`

For the next release, I clearly need a real test suite.
73 changes: 40 additions & 33 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Brain Connectivity Toolbox for Python version 0.5.0
[![Build Status](https://travis-ci.org/aestrivex/bctpy.svg?branch=master)](https://travis-ci.org/aestrivex/bctpy)

# Brain Connectivity Toolbox for Python version 0.5.0

Author: Roan LaPlante <rlaplant@nmr.mgh.harvard.edu>

==COPYRIGHT INFORMATION==
This program strictly observes the tenets of fundamentalist Theravada Mahasi
style Buddhism. Any use of this program in violation of these aforementioned
tenets or in violation of the principles described in the Visuddhimagga Sutta
## Copyright information

This program strictly observes the tenets of fundamentalist Theravada Mahasi
style Buddhism. Any use of this program in violation of these aforementioned
tenets or in violation of the principles described in the Visuddhimagga Sutta
is strictly prohibited and punishable by extensive Mahayana style practice.
By being or not being mindful of the immediate present moment sensations
involved in the use of this program, you confer your acceptance of these terms
Expand All @@ -14,11 +18,13 @@ Note that the observation of the tenets of fundamentalist Theravada Mahasi
style Buddhism and the Visuddhimagga Sutta is optional as long as the terms and
conditions of the GNU GPLv3+ are upheld.

==PACKAGES USED==
BCTPY is written in pure python and requires only scipy and numpy. scipy is
required for a couple of functions for its statistical and linear algebra
packages which have some features not available in numpy alone. If you don't
have scipy, most functions that do not need scipy functionality will still work.
## Packages used

BCTPY is written in pure python and requires only `scipy` and `numpy`. `scipy` is required for a couple of functions for its statistical and linear algebra
packages which have some features not available in `numpy` alone. If you don't
have `scipy`, most functions that do not need `scipy` functionality will still work.

Note that graphs must be passed in as `numpy.array`s rather than `numpy.matrix`es. Other constraints/ edge cases of the adjacency matrices (e.g. self-loops, negative weights) behave similarly to the matlab functions.

A small number of functions (notably including network-based statistics, a
nonparametric test for differences in undirected weighted graphs from different
Expand All @@ -27,16 +33,17 @@ point in the future.

Nosetests is used for the test suite. The test suite is not complete.

==ABOUT BCTPY AND OTHER AUTHORS==
BCT is a matlab toolbox with many graph theoretical measures off of which bctpy
## About `bctpy` and other authors

BCT is a matlab toolbox with many graph theoretical measures off of which `bctpy`
is based. I did not write BCT (apart from small bugfixes I have submitted)
and a quality of life improvements that I have taken liberties to add.
With few exceptions, bctpy is a direct translation of matlab code to python.
With few exceptions, `bctpy` is a direct translation of matlab code to python.

bctpy should be considered beta software, with BCT being the gold standard by
comparison. I did my best to test all functionality in bctpy, but much of it is
arcane math that flies over the head of this humble programmer. There *are*
bugs lurking in bctpy, the question is not whether but how many. If you locate
`bctpy` should be considered beta software, with BCT being the gold standard by
comparison. I did my best to test all functionality in `bctpy`, but much of it is
arcane math that flies over the head of this humble programmer. There *are*
bugs lurking in `bctpy`, the question is not whether but how many. If you locate
bugs, please submit them to me at rlaplant@nmr.mgh.harvard.edu.

Many thanks to Stefan Fuertinger for his assistance tracking down a number of
Expand All @@ -45,24 +52,24 @@ network functionality at http://research.mssm.edu/simonyanlab/analytical-tools/

Many thanks to Chris Barnes for his assistance in documenting a number of issues and facilitating a number of test cases.

Credit for writing BCT (the matlab version) goes to the following list of
Credit for writing BCT (the matlab version) goes to the following list of
authors, especially Olaf Sporns and Mika Rubinov.

Olaf Sporns
Mikail Rubinov
Yusuke Adachi
Andrea Avena
Danielle Bassett
Richard Betzel
Joaquin Goni
Alexandros Goulas
Patric Hagmann
Christopher Honey
Martijn van den Heuvel
Rolf Kotter
Jonathan Power
Murray Shanahan
Andrew Zalesky
- Olaf Sporns
- Mikail Rubinov
- Yusuke Adachi
- Andrea Avena
- Danielle Bassett
- Richard Betzel
- Joaquin Goni
- Alexandros Goulas
- Patric Hagmann
- Christopher Honey
- Martijn van den Heuvel
- Rolf Kotter
- Jonathan Power
- Murray Shanahan
- Andrew Zalesky

In order to be a bit more compact I have removed the accreditations from the
docstrings each functions. This does not in any way mean that I wish to take
Expand Down
4 changes: 1 addition & 3 deletions bct/algorithms/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,7 @@ def transitivity_bd(A):
S = A + A.T # symmetrized input graph
K = np.sum(S, axis=1) # total degree (in+out)
cyc3 = np.diag(np.dot(S, np.dot(S, S))) / 2 # number of 3-cycles
K[np.where(cyc3 == 0)] = np.inf # if no 3-cycles exist, make C=0
# number of all possible 3-cycles
CYC3 = K * (K - 1) - 2 * np.diag(np.dot(A, A))
CYC3 = K * (K - 1) - 2 * np.diag(np.dot(A, A)) # number of all possible 3-cycles
return np.sum(cyc3) / np.sum(CYC3)


Expand Down
2 changes: 0 additions & 2 deletions bct/algorithms/modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ def recur(module):
n = len(module)
modmat = B[module][:, module]

np.save('latest_modmat.npy', modmat)

vals, vecs = linalg.eig(modmat) # biggest eigendecomposition
rlvals = np.real(vals)
max_eigvec = np.squeeze(vecs[:, np.where(rlvals == np.max(rlvals))])
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def read(fname):
maintainer_email="rlaplant@nmr.mgh.harvard.edu",
description=("Brain Connectivity Toolbox for Python"),
license="Visuddhimagga Sutta; GPLv3+",
long_description=read('README'),
datafiles=[('', ['README', 'LICENSE'])],
long_description=read('README.md'),
datafiles=[('', ['README.md', 'LICENSE'])],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: X11 Applications",
Expand Down

0 comments on commit 24df43b

Please sign in to comment.