Skip to content

Commit

Permalink
travis fixes (#584)
Browse files Browse the repository at this point in the history
* code style fix

* Also added a commit that fixes code style

* trying to fix travis
  • Loading branch information
ericmjl authored Jan 5, 2020
1 parent 0bbc4a7 commit bfb9b10
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This is necessary for nxviz as matplotlib is involved.
before_script:
- "export DISPLAY=:99.0"
# before_script:
# - "export DISPLAY=:99.0"
# - "sh -e /etc/init.d/xvfb start"
- sleep 5 # give xvfb some time to start
# - sleep 5 # give xvfb some time to start

language: python
matrix:
Expand All @@ -29,7 +29,7 @@ install:

# Install Python, py.test, and required packages.
- conda env create -f environment.yml
- conda install python=$PYTHON_VERSION
- conda install python=$PYTHON_VERSION matplotlib-base
- source activate nxviz
- python setup.py install

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
- ericmjl
dependencies:
- python=3.6
- matplotlib
- matplotlib-base
- networkx
- numpy
- pip
Expand Down
8 changes: 4 additions & 4 deletions nxviz/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def draw(self):

def compute_node_colors(self):
"""Compute the node colors. Also computes the colorbar."""
data = [self.graph.node[n][self.node_color] for n in self.nodes]
data = [self.graph.nodes[n][self.node_color] for n in self.nodes]

if self.group_order == "alphabetically":
data_reduced = sorted(list(set(data)))
Expand Down Expand Up @@ -522,7 +522,7 @@ def compute_group_label_positions(self):
Computes the x,y positions of the group labels.
"""
assert self.group_label_position in ["beginning", "middle", "end"]
data = [self.graph.node[n][self.node_grouping] for n in self.nodes]
data = [self.graph.nodes[n][self.node_grouping] for n in self.nodes]
node_length = len(data)
groups = items_in_groups(data)

Expand Down Expand Up @@ -1154,8 +1154,8 @@ def compute_node_positions(self):
self.locs = dict()

for node in self.nodes:
x = self.graph.node[node][self.node_lon]
y = self.graph.node[node][self.node_lat]
x = self.graph.nodes[node][self.node_lon]
y = self.graph.nodes[node][self.node_lat]
xs.append(x)
ys.append(y)
self.locs[node] = (x, y)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

G_geo = G.copy()
for n, d in G_geo.nodes(data=True):
G_geo.node[n]["latitude"] = random()
G_geo.node[n]["longitude"] = random()
G_geo.node[n]["dpcapacity"] = random()
G_geo.nodes[n]["latitude"] = random()
G_geo.nodes[n]["longitude"] = random()
G_geo.nodes[n]["dpcapacity"] = random()

baseline_dir, result_dir = _image_directories(lambda: "dummy func")

Expand Down Expand Up @@ -100,7 +100,7 @@ def test_node_size():
# add size as attribute and fill with random numbers
nodes = G.nodes()
for u in nodes:
G.node[u]["score"] = random()
G.nodes[u]["score"] = random()
# also extract list for testing
scores = [G.nodes[u]["score"] for u in nodes]
# add color as property
Expand Down
5 changes: 3 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ def diff_plots(plot, plot_fn, baseline_dir, result_dir):
diff = compare_images(baseline_img_path, result_img_path, tol=0)
return diff


def corresponding_lists(x, y):
'''Returns True is both lists x and y have one to one mapping
"""Returns True is both lists x and y have one to one mapping
e.g:
x = [12, 4, 12, 3]
y = [44, 6, 44, 9]
corresponding_lists(x, y) # True
'''
"""
unique_mapping_pairs = set(zip(x, y))
unique_elements = set(y)
return len(unique_mapping_pairs) == len(unique_elements)

0 comments on commit bfb9b10

Please sign in to comment.