Commit 6ad35ea3 authored by Tiago Peixoto's avatar Tiago Peixoto

Replace '== None' by 'is None'

parent 1966c234
......@@ -908,7 +908,7 @@ class PropertyArray(numpy.ndarray):
def _check_prop_writable(prop, name=None):
if not prop.is_writable():
raise ValueError("property map%s is not writable." %\
((" '%s'" % name) if name != None else ""))
((" '%s'" % name) if name is not None else ""))
def _check_prop_scalar(prop, name=None, floating=False):
......@@ -919,7 +919,7 @@ def _check_prop_scalar(prop, name=None, floating=False):
if prop.value_type() not in scalars:
raise ValueError("property map%s is not of scalar%s type." %\
(((" '%s'" % name) if name != None else ""),
(((" '%s'" % name) if name is not None else ""),
(" floating" if floating else "")))
......@@ -933,7 +933,7 @@ def _check_prop_vector(prop, name=None, scalar=True, floating=False):
vals = ["vector<%s>" % v for v in scalars]
if prop.value_type() not in vals:
raise ValueError("property map%s is not of vector%s type." %\
(((" '%s'" % name) if name != None else ""),
(((" '%s'" % name) if name is not None else ""),
(" floating" if floating else "")))
......@@ -987,11 +987,11 @@ def group_vector_property(props, value_type=None, vprop=None, pos=None):
raise ValueError("'props' must be of the same key type.")
k = keys.pop()
if vprop == None:
if value_type == None and len(vtypes) == 1:
if vprop is None:
if value_type is None and len(vtypes) == 1:
value_type = vtypes.pop()
if value_type != None:
if value_type is not None:
value_type = "vector<%s>" % value_type
if k == 'v':
vprop = g.new_vertex_property(value_type)
......@@ -1010,7 +1010,7 @@ def group_vector_property(props, value_type=None, vprop=None, pos=None):
skip_properties=True)
libcore.group_vector_property(u._Graph__graph, _prop(k, g, vprop),
_prop(k, g, p),
i if pos == None else pos[i],
i if pos is None else pos[i],
k == 'e')
else:
vprop[g][i if pos is None else pos[i]] = p[g]
......@@ -1057,7 +1057,7 @@ def ungroup_vector_property(vprop, pos, props=None):
_check_prop_vector(vprop, name="vprop", scalar=False)
k = vprop.key_type()
value_type = vprop.value_type().split("<")[1].split(">")[0]
if props == None:
if props is None:
if k == 'v':
props = [g.new_vertex_property(value_type) for i in pos]
elif k == 'e':
......@@ -2830,7 +2830,7 @@ class GraphView(Graph):
``True`` if a given vertex/edge is to be selected, or ``False`` otherwise.
The boolean parameter ``directed`` can be used to set the directionality of
the graph view. If ``directed == None``, the directionality is inherited
the graph view. If ``directed is None``, the directionality is inherited
from ``g``.
If ``reversed == True``, the direction of the edges is reversed.
......
......@@ -212,9 +212,9 @@ def pagerank(g, damping=0.85, pers=None, weight=None, prop=None, epsilon=1e-6,
Weblogging Ecosystem (2005). :DOI:`10.1145/1134271.1134277`
"""
if max_iter == None:
if max_iter is None:
max_iter = 0
if prop == None:
if prop is None:
prop = g.new_vertex_property("double")
N = len(prop.fa)
prop.fa = pers.fa[:N] if pers is not None else 1. / g.num_vertices()
......@@ -323,11 +323,11 @@ def betweenness(g, vprop=None, eprop=None, weight=None, norm=True):
and the 2004 US Election", in Proceedings of the WWW-2005 Workshop on the
Weblogging Ecosystem (2005). :DOI:`10.1145/1134271.1134277`
"""
if vprop == None:
if vprop is None:
vprop = g.new_vertex_property("double")
if eprop == None:
if eprop is None:
eprop = g.new_edge_property("double")
if weight != None and weight.value_type() != eprop.value_type():
if weight is not None and weight.value_type() != eprop.value_type():
nw = g.new_edge_property(eprop.value_type())
g.copy_property(weight, nw)
weight = nw
......@@ -447,7 +447,7 @@ def closeness(g, weight=None, source=None, vprop=None, norm=True, harmonic=False
"""
if source is None:
if vprop == None:
if vprop is None:
vprop = g.new_vertex_property("double")
libgraph_tool_centrality.\
closeness(g._Graph__graph, _prop("e", g, weight),
......@@ -1005,7 +1005,7 @@ def eigentrust(g, trust_map, vprop=None, norm=False, epsilon=1e-6, max_iter=0,
Weblogging Ecosystem (2005). :DOI:`10.1145/1134271.1134277`
"""
if vprop == None:
if vprop is None:
vprop = g.new_vertex_property("double")
i = libgraph_tool_centrality.\
get_eigentrust(g._Graph__graph, _prop("e", g, trust_map),
......@@ -1138,15 +1138,15 @@ def trust_transitivity(g, trust_map, source=None, target=None, vprop=None):
"""
if vprop == None:
if vprop is None:
vprop = g.new_vertex_property("vector<double>")
if target == None:
if target is None:
target = -1
else:
target = g.vertex_index[target]
if source == None:
if source is None:
source = -1
else:
source = g.vertex_index[source]
......
......@@ -277,7 +277,7 @@ def extended_clustering(g, props=None, max_depth=3, undirected=False):
if g.is_directed() and undirected:
g = GraphView(g, directed=False)
if props == None:
if props is None:
props = []
for i in range(0, max_depth):
props.append(g.new_vertex_property("double"))
......
......@@ -524,7 +524,7 @@ def graphviz_draw(g, pos=None, size=(15, 15), pin=False, layout=None,
has_layout = True
retv = libgv.gvRender(gvc, gvg, "dot".encode("utf8"), None) # retrieve positions only
if pos == None:
if pos is None:
pos = (g.new_vertex_property("double"),
g.new_vertex_property("double"))
for v in g.vertices():
......
......@@ -170,7 +170,7 @@ def edmonds_karp_max_flow(g, source, target, capacity, residual=None):
"""
_check_prop_scalar(capacity, "capacity")
if residual == None:
if residual is None:
residual = g.new_edge_property(capacity.value_type())
_check_prop_scalar(residual, "residual")
_check_prop_writable(residual, "residual")
......@@ -247,7 +247,7 @@ def push_relabel_max_flow(g, source, target, capacity, residual=None):
"""
_check_prop_scalar(capacity, "capacity")
if residual == None:
if residual is None:
residual = g.new_edge_property(capacity.value_type())
_check_prop_scalar(residual, "residual")
_check_prop_writable(residual, "residual")
......@@ -333,7 +333,7 @@ def boykov_kolmogorov_max_flow(g, source, target, capacity, residual=None):
:doi:`10.1109/TPAMI.2004.60`
"""
_check_prop_scalar(capacity, "capacity")
if residual == None:
if residual is None:
residual = g.new_edge_property(capacity.value_type())
_check_prop_scalar(residual, "residual")
_check_prop_writable(residual, "residual")
......
......@@ -92,9 +92,9 @@ def random_graph(N, deg_sampler, directed=True,
degree sequence cannot be used to build a graph.
Optionally, you can also pass a function which receives one or two
arguments. If ``block_membership == None``, the single argument passed
arguments. If ``block_membership is None``, the single argument passed
will be the index of the vertex which will receive the degree. If
``block_membership != None``, the first value passed will be the vertex
``block_membership is not None``, the first value passed will be the vertex
index, and the second will be the block value of the vertex.
directed : bool (optional, default: ``True``)
Whether the generated graph should be directed.
......@@ -121,7 +121,7 @@ def random_graph(N, deg_sampler, directed=True,
:func:`~graph_tool.generation.random_rewire` function which specifies
the correlation matrix.
block_type : string (optional, default: ``"int"``)
Value type of block labels. Valid only if ``block_membership != None``.
Value type of block labels. Valid only if ``block_membership is not None``.
degree_block : bool (optional, default: ``False``)
If ``True``, the degree of each vertex will be appended to block labels
when constructing the blockmodel, such that the resulting block type
......@@ -139,7 +139,7 @@ def random_graph(N, deg_sampler, directed=True,
The generated graph.
blocks : :class:`~graph_tool.PropertyMap`
A vertex property map with the block values. This is only returned if
``block_membership != None``.
``block_membership is not None``.
See Also
--------
......@@ -1832,7 +1832,7 @@ class Sampler(libgraph_tool_generation.Sampler):
class DynamicSampler(libgraph_tool_generation.DynamicSampler):
def __init__(self, values=None, probs=None):
if values == None:
if values is None:
values = probs = []
libgraph_tool_generation.DynamicSampler.__init__(self, values, probs)
......
......@@ -1429,13 +1429,13 @@ class BlockState(object):
Function to be called for each partition, with three arguments ``(S,
S_min, b_min)`` corresponding to the the current entropy value, the
minimum entropy value so far, and the corresponding partition,
respectively. If not provided, and ``hist == None`` an iterator over
respectively. If not provided, and ``hist is None`` an iterator over
the same values will be returned instead.
density : ``tuple`` (optional, default: ``None``)
If provided, it should contain a tuple with values ``(S_min, S_max,
n_bins)``, which will be used to obtain the density of states via a
histogram of size ``n_bins``. This parameter is ignored unless
``callback == None``.
``callback is None``.
vertices : iterable of ints (optional, default: ``None``)
If provided, this should be a list of vertices which will be
moved. Otherwise, all vertices will.
......
......@@ -136,7 +136,7 @@ def adjacency(g, weight=None, index=None):
"""
if index is None:
if g.get_vertex_filter()[0] != None:
if g.get_vertex_filter()[0] is not None:
index = g.new_vertex_property("int64_t")
index.fa = numpy.arange(g.num_vertices())
else:
......@@ -285,7 +285,7 @@ def laplacian(g, deg="total", normalized=False, weight=None, index=None):
"""
if index is None:
if g.get_vertex_filter()[0] != None:
if g.get_vertex_filter()[0] is not None:
index = g.new_vertex_property("int64_t")
index.fa = numpy.arange(g.num_vertices())
else:
......@@ -383,14 +383,14 @@ def incidence(g, vindex=None, eindex=None):
"""
if vindex is None:
if g.get_edge_filter()[0] != None:
if g.get_edge_filter()[0] is not None:
vindex = g.new_vertex_property("int64_t")
vindex.fa = numpy.arange(g.num_vertices())
else:
vindex = g.vertex_index
if eindex is None:
if g.get_edge_filter()[0] != None:
if g.get_edge_filter()[0] is not None:
eindex = g.new_edge_property("int64_t")
eindex.fa = numpy.arange(g.num_edges())
else:
......@@ -489,7 +489,7 @@ def transition(g, weight=None, index=None):
"""
if index is None:
if g.get_vertex_filter()[0] != None:
if g.get_vertex_filter()[0] is not None:
index = g.new_vertex_property("int64_t")
index.fa = numpy.arange(g.num_vertices())
else:
......
......@@ -386,7 +386,7 @@ def distance_histogram(g, weight=None, bins=[0, 1], samples=None,
and starting from the first value.
samples : int (optional, default: None)
If supplied, the distances will be randomly sampled from a number of
source vertices given by this parameter. It `samples == None` (default),
source vertices given by this parameter. It `samples is None` (default),
all pairs are used.
float_count : bool (optional, default: True)
If True, the counts in each histogram bin will be returned as floats. If
......@@ -409,7 +409,7 @@ def distance_histogram(g, weight=None, bins=[0, 1], samples=None,
Notes
-----
The algorithm runs in :math:`O(V^2)` time, or :math:`O(V^2\log V)` if
`weight != None`. If `samples` is supplied, the complexities are
`weight is not None`. If `samples` is supplied, the complexities are
:math:`O(\text{samples}\times V)` and
:math:`O(\text{samples}\times V\log V)`, respectively.
......
......@@ -247,7 +247,7 @@ def vertex_similarity(g, sim_type="jaccard", vertex_pairs=None, self_loops=True,
If ``True``, vertices will be considered adjacent to themselves for the
purpose of the similarity computation.
sim_map : :class:`~graph_tool.PropertyMap` (optional, default: ``None``)
If provided, and ``vertex_pairs == None``, the vertex similarities will
If provided, and ``vertex_pairs is None``, the vertex similarities will
be stored in this vector-valued property. Otherwise, a new one will be
created.
......@@ -290,7 +290,7 @@ def vertex_similarity(g, sim_type="jaccard", vertex_pairs=None, self_loops=True,
reversed=True))``.
The algorithm runs with complexity :math:`O(\left<k\right>N^2)` if
``vertex_pairs == None``, otherwise with :math:`O(\left<k\right>P)` where
``vertex_pairs is None``, otherwise with :math:`O(\left<k\right>P)` where
:math:`P` is the length of ``vertex_pairs``.
If enabled during compilation, this algorithm runs in parallel.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment