Skip to content

Commit

Permalink
style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wiheto committed Nov 12, 2019
1 parent 2b7cc34 commit 01cf1f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
## V0.4.7 (development branch)

### Improvements
- Changing name argument names in network measures to 'pertime' and 'overtime' replacing 'time' and 'global' to be clearer.
- More detailed documentation to temporal_degree_centrality.

- Changing name argument names in network measures to 'pertime' and 'overtime' replacing 'time' and 'global' to be clearer.
- More detailed documentation to temporal_degree_centrality.

## Changes

- Python 3.6 is now required.
- Python 3.6 is now required.

## V0.4.6

Expand All @@ -27,7 +28,6 @@
- Fixing case where, for array input, get_network_when with directed edges dropped duplicates.
- Fixed missing bracket in get_network_when (credit to: lcandeago #45)


## V0.4.5

### Enhancements
Expand All @@ -44,7 +44,7 @@

### Fixes

- NaNs in allegiance, which fixes recruitment and integration. Also added squeeze to input. And bug in integration where for loop would generate error.
- NaNs in allegiance, which fixes recruitment and integration. Also added squeeze to input. And bug in integration where for loop would generate error.

- Removed self from teneto history.

Expand Down
13 changes: 7 additions & 6 deletions teneto/classes/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def __init__(self, N=None, T=None, nettype=None, from_df=None, from_array=None,
T : int
number of time-points in network
nettype : str
description of network. Can be: bu, bd, wu, wd where the letters stand for binary, weighted, undirected and directed. Default is weighted undirected
description of network. Can be: bu, bd, wu, wd where the letters stand for binary, weighted, undirected and directed.
Default is weighted and undirected.
from_df : pandas df
input data frame with i,j,t,[weight] columns
from_array : array
Expand Down Expand Up @@ -150,7 +151,7 @@ def __init__(self, N=None, T=None, nettype=None, from_df=None, from_array=None,
self._calc_netshape()
if not self.diagonal:
self._drop_diagonal()
if nettype and self.sparse == True:
if nettype and self.sparse:
if nettype[1] == 'u':
self._drop_duplicate_ij()

Expand Down Expand Up @@ -196,7 +197,7 @@ def network_from_array(self, array, forcesparse=False):
if len(array.shape) == 2:
array = np.array(array, ndmin=3).transpose([1, 2, 0])
teneto.utils.check_TemporalNetwork_input(array, 'array')
if np.sum([array == 0]) > np.prod(array.shape)*0.75 or forcesparse == True:
if np.sum([array == 0]) > np.prod(array.shape)*0.75 or forcesparse:
uvals = np.unique(array)
if len(uvals) == 2 and 1 in uvals and 0 in uvals:
i, j, t = np.where(array == 1)
Expand Down Expand Up @@ -285,7 +286,7 @@ def _drop_diagonal(self):
"""
Drops self-contacts from the network dataframe.
"""
if self.sparse == True:
if self.sparse:
self.network = self.network.where(
self.network['i'] != self.network['j']).dropna()
self.network.reset_index(inplace=True, drop=True)
Expand All @@ -297,7 +298,7 @@ def _calc_netshape(self):
"""
if len(self.network) == 0:
self.netshape = (0, 0)
elif self.sparse == False:
elif not self.sparse:
N = int(self.network.shape[0])
T = int(self.network.shape[-1])
self.netshape = (N, T)
Expand Down Expand Up @@ -328,7 +329,7 @@ def add_edge(self, edgelist):
--------
Updates TenetoBIDS.network dataframe with new edge
"""
if self.sparse == False:
if not self.sparse:
raise ValueError('Add edge not compatible with dense network')
if not isinstance(edgelist[0], list):
edgelist = [edgelist]
Expand Down

0 comments on commit 01cf1f0

Please sign in to comment.