Skip to content

Commit

Permalink
Merge pull request #3219 from jarrodmillman/python3
Browse files Browse the repository at this point in the history
3.7 default and drop 2.7 for CI
  • Loading branch information
jarrodmillman committed Nov 15, 2018
2 parents a57ed5c + fcc8217 commit 8f4845e
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 87 deletions.
8 changes: 0 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ environment:
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\tools\\appveyor\\run_with_env.cmd"

matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.15"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.15"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.3"
PYTHON_ARCH: "32"
Expand Down
31 changes: 7 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ cache:
matrix:
include:
- os: linux
python: 2.7
python: 3.7
dist: xenial
sudo: true
env:
- OPTIONAL_DEPS=1
- BUILD_DOCS=1
Expand All @@ -26,7 +28,9 @@ matrix:
- texlive-latex-extra
- latexmk
- os: linux
python: 2.7
python: 3.7
dist: xenial
sudo: true
env:
- OPTIONAL_DEPS=1
- MINIMUM_REQUIREMENTS=1
Expand All @@ -36,33 +40,13 @@ matrix:
packages:
- libgdal-dev
- graphviz
- os: linux
python: 2.7
env:
- OPTIONAL_DEPS=1
- PIP_FLAGS="--pre"
addons:
apt:
packages:
- libgdal-dev
- graphviz
- os: linux
python: 3.7
dist: xenial
sudo: true
env: OPTIONAL_DEPS=1
addons:
apt:
packages:
- libgdal-dev
- graphviz
- os: linux
python: 3.7
dist: xenial
sudo: true
env:
- OPTIONAL_DEPS=1
- MINIMUM_REQUIREMENTS=1
- PIP_FLAGS="--pre"
addons:
apt:
packages:
Expand All @@ -78,7 +62,6 @@ matrix:
- os: osx
language: generic
env: TRAVIS_PYTHON_VERSION=3.7
- python: 2.7
- python: 3.5
- python: 3.6
- python: 3.7
Expand Down
6 changes: 3 additions & 3 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Install
=======

NetworkX requires Python 2.7, 3.5, 3.6, or 3.7. If you do not already
NetworkX requires Python 3.5, 3.6, or 3.7. If you do not already
have a Python environment configured on your computer, please see the
instructions for installing the full `scientific Python stack
<https://scipy.org/install.html>`_.
Expand Down Expand Up @@ -87,14 +87,14 @@ Optional packages

The following optional packages provide additional functionality.

- `NumPy <http://www.numpy.org/>`_ (>= 1.15.0) provides matrix representation of
- `NumPy <http://www.numpy.org/>`_ (>= 1.15.4) provides matrix representation of
graphs and is used in some graph algorithms for high-performance matrix
computations.
- `SciPy <http://scipy.org/>`_ (>= 1.1.0) provides sparse matrix representation
of graphs and many numerical scientific tools.
- `pandas <http://pandas.pydata.org/>`_ (>= 0.23.3) provides a DataFrame, which
is a tabular data structure with labeled axes.
- `Matplotlib <http://matplotlib.org/>`_ (>= 2.2.2) provides flexible drawing of
- `Matplotlib <http://matplotlib.org/>`_ (>= 3.0.2) provides flexible drawing of
graphs.
- `PyGraphviz <http://pygraphviz.github.io/>`_ (>= 1.5) and
`pydot <https://github.com/erocarrera/pydot>`_ (>= 1.2.4) provide graph drawing
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ edges $(A, B)$ and $(B, C)$.
>>> G.add_edge('A', 'B')
>>> G.add_edge('B', 'C')
>>> print(G.adj)
{'A': {'B': {}}, 'C': {'B': {}}, 'B': {'A': {}, 'C': {}}}
{'A': {'B': {}}, 'B': {'A': {}, 'C': {}}, 'C': {'B': {}}}

The data structure gets morphed slightly for each base graph class.
For DiGraph two dict-of-dicts-of-dicts structures are provided, one
Expand Down
2 changes: 1 addition & 1 deletion doc/release/api_1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ keyword arguments.
>>> G=nx.Graph(region='Africa')
>>> G.graph['color']='green'
>>> G.graph
{'color': 'green', 'region': 'Africa'}
{'region': 'Africa', 'color': 'green'}

Node attributes
---------------
Expand Down
19 changes: 10 additions & 9 deletions doc/release/migration_guide_from_1.x_to_2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ views.
>>> H = nx.Graph()
>>> H.add_nodes_from([1, 'networkx', '2.0'])
>>> G.nodes & H.nodes # finding common nodes in 2 graphs
set([1])
>>> G.nodes | H.nodes # union of nodes in 2 graphs
set([0, 1, 2, 3, 4, 'networkx', '2.0'])
{1}
>>> # union of nodes in 2 graphs
>>> G.nodes | H.nodes # doctest: +SKIP
{0, 1, 2, 3, 4, 'networkx', '2.0'}

Similarly, ``G.edges`` now returns an EdgeView instead of a list of edges and it
also supports set operations.
Expand Down Expand Up @@ -131,7 +132,7 @@ for ``out_degree`` and ``degree``
[1, 0]

>>> dict(DG.in_degree([1, 3])).values() # works for nx-1 and nx-2
[1, 0]
dict_values([1, 0])
>>> # DG.in_degree(nlist) creates a restricted view for only nodes in nlist.
>>> # but see the fourth option above for using lookup instead.
>>> list(d for n, d in DG.in_degree([1, 3]))
Expand All @@ -148,7 +149,7 @@ If ``n`` is a node in ``G``, then ``G.neighbors(n)`` returns an iterator.

>>> n = 1
>>> G.neighbors(n)
<dictionary-keyiterator object at ...>
<dict_keyiterator object at ...>
>>> list(G.neighbors(n))
[0, 2, 3, 4]

Expand All @@ -169,9 +170,9 @@ DiGraphViews behave similar to GraphViews, but have a few more methods.
>>> D.out_degree[2]
2
>>> D.in_edges
InEdgeView([(1, 2), (1, 3), (2, 3), (2, 4)])
InEdgeView([(1, 2), (2, 3), (1, 3), (2, 4)])
>>> list(D.in_edges())
[(1, 2), (1, 3), (2, 3), (2, 4)]
[(1, 2), (2, 3), (1, 3), (2, 4)]
>>> D.out_edges(2)
OutEdgeDataView([(2, 3), (2, 4)])
>>> list(D.out_edges(2))
Expand All @@ -181,11 +182,11 @@ DiGraphViews behave similar to GraphViews, but have a few more methods.
>>> list(D.in_degree)
[(1, 0), (2, 1), (3, 2), (4, 1)]
>>> D.successors(2)
<dictionary-keyiterator object at ...>
<dict_keyiterator object at ...>
>>> list(D.successors(2))
[3, 4]
>>> D.predecessors(2)
<dictionary-keyiterator object at ...>
<dict_keyiterator object at ...>
>>> list(D.predecessors(2))
[1]

Expand Down
2 changes: 1 addition & 1 deletion doc/release/release_2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ API Changes
>>> G.nodes[3]
{'color': 'blue'}
>>> G.nodes & {3, 4, 5}
set([3, 4])
{3, 4}

The following methods have changed:

Expand Down
8 changes: 4 additions & 4 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ better in other contexts.
.. nbplot::

>>> list(G.nodes)
['a', 1, 2, 3, 'spam', 'm', 'p', 's']
[1, 2, 3, 'spam', 's', 'p', 'a', 'm']
>>> list(G.edges)
[(1, 2), (1, 3), (3, 'm')]
>>> list(G.adj[1]) # or list(G.neighbors(1))
Expand Down Expand Up @@ -296,7 +296,7 @@ Add node attributes using ``add_node()``, ``add_nodes_from()``, or ``G.nodes``
{'time': '5pm'}
>>> G.nodes[1]['room'] = 714
>>> G.nodes.data()
NodeDataView({1: {'room': 714, 'time': '5pm'}, 3: {'time': '2pm'}})
NodeDataView({1: {'time': '5pm', 'room': 714}, 3: {'time': '2pm'}})

Note that adding a node to ``G.nodes`` does not add it to the graph, use
``G.add_node()`` to add new nodes. Similarly for edges.
Expand Down Expand Up @@ -450,7 +450,7 @@ functions such as:
>>> G.add_edges_from([(1, 2), (1, 3)])
>>> G.add_node("spam") # adds node "spam"
>>> list(nx.connected_components(G))
[set([1, 2, 3]), set(['spam'])]
[{1, 2, 3}, {'spam'}]
>>> sorted(d for n, d in G.degree())
[0, 1, 1, 2]
>>> nx.clustering(G)
Expand All @@ -463,7 +463,7 @@ These are easily stored in a `dict` structure if you desire.

>>> sp = dict(nx.all_pairs_shortest_path(G))
>>> sp[3]
{1: [3, 1], 2: [3, 1, 2], 3: [3]}
{3: [3], 1: [3, 1], 2: [3, 1, 2]}

See :doc:`/reference/algorithms/index` for details on graph algorithms
supported.
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/plot_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import networkx as nx

G = nx.grid_2d_graph(5, 5) # 5x5 grid
try: # Python 2.6+
nx.write_adjlist(G, sys.stdout) # write adjacency list to screen
except TypeError: # Python 3.x
nx.write_adjlist(G, sys.stdout.buffer) # write adjacency list to screen

# print the adjacency list
for line in nx.generate_adjlist(G):
print(line)
# write edgelist to grid.edgelist
nx.write_edgelist(G, path="grid.edgelist", delimiter=":")
# read edgelist from grid.edgelist
Expand Down
14 changes: 3 additions & 11 deletions examples/drawing/plot_unix_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# All rights reserved.
# BSD license.

import email
from email.utils import getaddresses, parseaddr
import mailbox
import sys
Expand All @@ -35,25 +34,18 @@
import networkx as nx

# unix mailbox recipe
# see https://docs.python.org/2/library/mailbox.html

# see https://docs.python.org/3/library/mailbox.html

def mbox_graph():
try:
fh = open("unix_email.mbox", 'rb')
except IOError:
print("unix_email.mbox not found")
raise

mbox = mailbox.UnixMailbox(fh, email.message_from_file) # parse unix mailbox
mbox = mailbox.mbox("unix_email.mbox") # parse unix mailbox

G = nx.MultiDiGraph() # create empty graph

# parse each messages and build graph
for msg in mbox: # msg is python email.Message.Message object
(source_name, source_addr) = parseaddr(msg['From']) # sender
# get all recipients
# see https://docs.python.org/2/library/email.html
# see https://docs.python.org/3/library/email.html
tos = msg.get_all('to', [])
ccs = msg.get_all('cc', [])
resent_tos = msg.get_all('resent-to', [])
Expand Down
10 changes: 3 additions & 7 deletions examples/graph/plot_erdos_renyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# All rights reserved.
# BSD license.

import sys

import matplotlib.pyplot as plt
from networkx import nx

Expand All @@ -36,11 +34,9 @@
for v in nx.nodes(G):
print('%s %d %f' % (v, nx.degree(G, v), nx.clustering(G, v)))

# print the adjacency list to terminal
try:
nx.write_adjlist(G, sys.stdout)
except TypeError: # Python 3.x
nx.write_adjlist(G, sys.stdout.buffer)
# print the adjacency list
for line in nx.generate_adjlist(G):
print(line)

nx.draw(G)
plt.show()
4 changes: 2 additions & 2 deletions networkx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
from __future__ import absolute_import

import sys
if sys.version_info[:2] < (2, 7):
m = "Python 2.7 or later is required for NetworkX (%d.%d detected)."
if sys.version_info[:2] < (3, 5):
m = "Python 3.5 or later is required for NetworkX (%d.%d detected)."
raise ImportError(m % sys.version_info[:2])
del sys

Expand Down
2 changes: 1 addition & 1 deletion networkx/drawing/nx_pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ def apply_alpha(colors, alpha, elem_list, cmap=None, vmin=None, vmax=None):
# rgba_colors) is the same as the number of elements, resize the array,
# to avoid it being interpreted as a colormap by scatter()
if len(alpha) > len(rgba_colors) or rgba_colors.size == len(elem_list):
rgba_colors.resize((len(elem_list), 4))
rgba_colors = np.resize(rgba_colors, (len(elem_list), 4))
rgba_colors[1:, 0] = rgba_colors[0, 0]
rgba_colors[1:, 1] = rgba_colors[0, 1]
rgba_colors[1:, 2] = rgba_colors[0, 2]
Expand Down
2 changes: 0 additions & 2 deletions networkx/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ def get_info(dynamic=True):
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down
8 changes: 4 additions & 4 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx>=1.7.6
sphinx_rtd_theme>=0.4.1
sphinx>=1.8.1
sphinx_rtd_theme>=0.4.2
sphinx-gallery>=0.2.0
pillow>=5.2.0
pillow>=5.3.0
nb2plots>=0.6
texext>=0.6
texext>=0.6.1
4 changes: 2 additions & 2 deletions requirements/extras.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy>=1.15.0
numpy>=1.15.4
scipy>=1.1.0
pandas>=0.23.3
matplotlib>=2.2.2
matplotlib>=3.0.2
pygraphviz>=1.5
pydot>=1.2.4
pyyaml>=3.13
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nose>=1.3.7
nose-ignore-docstring>=0.2
coverage>=4.5.1
coverage>=4.5.2
codecov>=2.0.15
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
print("To install, run 'python setup.py install'")
print()

if sys.version_info[:2] < (2, 7):
print("NetworkX requires Python 2.7 or later (%d.%d detected)." %
if sys.version_info[:2] < (3, 5):
print("NetworkX requires Python 3.5 or later (%d.%d detected)." %
sys.version_info[:2])
sys.exit(-1)

Expand Down

0 comments on commit 8f4845e

Please sign in to comment.