Skip to content

Commit

Permalink
Linting & Formatting - 2023-10-03 (#749)
Browse files Browse the repository at this point in the history
* update pre-commit

* reup linting and formatting
  • Loading branch information
jGaboardi authored Oct 3, 2023
1 parent 0054b7f commit 0254ca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
files: 'spaghetti\/'
files: "spaghetti\/"
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
rev: "23.9.1"
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.278"
rev: "v0.0.292"
hooks:
- id: ruff

Expand Down
10 changes: 5 additions & 5 deletions spaghetti/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ def allneighbordistances(
self.full_distance_matrix(n_processes, gen_tree=gen_tree)

# set the source and destination observation point patterns
if type(sourcepattern) is str:
if isinstance(sourcepattern, str):
sourcepattern = self.pointpatterns[sourcepattern]
if destpattern:
destpattern = self.pointpatterns[destpattern]
Expand All @@ -1768,7 +1768,7 @@ def allneighbordistances(
symmetric = True
destpattern = sourcepattern
# set local copy of destination pattern index
dest_indices = list(destpattern.points.keys())
dest_indices = list(destpattern.points)
# set local copy of destination distance to vertex lookup
dst_d2v = copy.deepcopy(destpattern.dist_to_vertex)
# destination point count
Expand Down Expand Up @@ -2003,7 +2003,7 @@ def nearestneighbordistances(
"""

# raise exception is the specified point pattern does not exist
if sourcepattern not in self.pointpatterns.keys():
if sourcepattern not in self.pointpatterns:
raise KeyError(f"Available point patterns are {self.pointpatterns.keys()}")

# calculate the network vertex to vertex distance matrix
Expand Down Expand Up @@ -2282,7 +2282,7 @@ def int_coord(c):
"""convert coordinates for integers if possible
e.g., (1.0, 0.5) --> (1, 0.5)
"""
return int(c) if (type(c) == float and c.is_integer()) else c
return int(c) if (isinstance(c, float) and c.is_integer()) else c

# catch invalid split types
_split_by = split_by.lower()
Expand Down Expand Up @@ -2395,7 +2395,7 @@ def int_coord(c):
new_vertex = (int_coord(newx), int_coord(newy))

# update the vertex and coordinate info if needed
if new_vertex not in split_network.vertices.keys():
if new_vertex not in split_network.vertices:
split_network.vertices[new_vertex] = currentstop
split_network.vertex_coords[currentstop] = new_vertex
split_network.vertex_list.append(currentstop)
Expand Down

0 comments on commit 0254ca9

Please sign in to comment.