Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/noqa_colon_top_level' into noqa_…
Browse files Browse the repository at this point in the history
…colon_top_level
  • Loading branch information
jGaboardi committed Nov 19, 2023
2 parents 743a9ab + 14a78b6 commit 9b86f6d
Show file tree
Hide file tree
Showing 57 changed files with 118 additions and 118 deletions.
4 changes: 2 additions & 2 deletions libpysal/cg/alpha_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def nb_dist(x, y):
1.4142135623730951
"""
sum_ = 0
for x_i, y_i in zip(x, y): # noqa B905
for x_i, y_i in zip(x, y): # noqa: B905
sum_ += (x_i - y_i) ** 2
dist = np.sqrt(sum_)
return dist
Expand Down Expand Up @@ -651,7 +651,7 @@ def _construct_centers(a, b, radius):
return down_x, down_y


def _filter_holes(geoms, points): # noqa ARG001
def _filter_holes(geoms, points): # noqa: ARG001
"""
Filter hole polygons using a computational geometry solution
"""
Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def nearest(self, query_point, rule="vertex"):
>>> try: n = pl.nearest(Point((-1, 1)))
... except NotImplementedError: print("future test: str(min(n.vertices())) == (0.0, 1.0)")
future test: str(min(n.vertices())) == (0.0, 1.0)
""" # noqa E501
""" # noqa: E501
raise NotImplementedError

def region(self, region_rect):
Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/ops/_accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def get_attr(df, geom_col="geometry", inplace=False, attr=None):
outval = df[geom_col].apply(lambda x: x.__getattribute__(attr))
if inplace:
outcol = f"shape_{func.__name__}" # noqa F821
outcol = f"shape_{func.__name__}" # noqa: F821

Check warning on line 22 in libpysal/cg/ops/_accessors.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/ops/_accessors.py#L22

Added line #L22 was not covered by tests
df[outcol] = outval
return None
return outval
Expand Down
4 changes: 2 additions & 2 deletions libpysal/cg/ops/_shapely.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def unary_union(df, geom_col="geometry", **groupby_kws):
level = groupby_kws.pop("level", None)
if by is not None or level is not None:
df = df.groupby(**groupby_kws)
out = df[geom_col].apply(_cascaded_union) # noqa F821
out = df[geom_col].apply(_cascaded_union) # noqa: F821

Check warning on line 168 in libpysal/cg/ops/_shapely.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/ops/_shapely.py#L168

Added line #L168 was not covered by tests
else:
out = _cascaded_union(df[geom_col].tolist()) # noqa F821
out = _cascaded_union(df[geom_col].tolist()) # noqa: F821

Check warning on line 170 in libpysal/cg/ops/_shapely.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/ops/_shapely.py#L170

Added line #L170 was not covered by tests
return out


Expand Down
4 changes: 2 additions & 2 deletions libpysal/cg/ops/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def dissolve(df, by="", **groupby_kws):
return union(df, by=by, **groupby_kws)


def clip(return_exterior=False): # noqa ARG001
def clip(return_exterior=False): # noqa: ARG001
# return modified entries of the df that are within an envelope
# provide an option to null out the geometries instead of not returning
raise NotImplementedError


def erase(return_interior=True): # noqa ARG001
def erase(return_interior=True): # noqa: ARG001
# return modified entries of the df that are outside of an envelope
# provide an option to null out the geometries instead of not returning
raise NotImplementedError
Expand Down
8 changes: 4 additions & 4 deletions libpysal/cg/ops/tests/test_shapely.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ def setup_method(self):

def compare(self, func_name, df, **kwargs):
geom_list = df.geometry.tolist()
shefunc = she.__dict__[func_name] # noqa F821
shtfunc = sht.__dict__[func_name] # noqa F821
shefunc = she.__dict__[func_name] # noqa: F821
shtfunc = sht.__dict__[func_name] # noqa: F821

Check warning on line 31 in libpysal/cg/ops/tests/test_shapely.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/ops/tests/test_shapely.py#L30-L31

Added lines #L30 - L31 were not covered by tests

try:
she_vals = (shefunc(geom, **kwargs) for geom in geom_list)
sht_vals = shtfunc(df, inplace=False, **kwargs)
sht_list = sht_vals[f"shape_{func_name}"].tolist()
for tabular, shapely in zip(sht_list, she_vals, strict=True):
if comp.is_shape(tabular) and comp.is_shape(shapely): # noqa F821
comp.equal(tabular, shapely) # noqa F821
if comp.is_shape(tabular) and comp.is_shape(shapely): # noqa: F821
comp.equal(tabular, shapely) # noqa: F821

Check warning on line 39 in libpysal/cg/ops/tests/test_shapely.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/ops/tests/test_shapely.py#L38-L39

Added lines #L38 - L39 were not covered by tests
else:
assert tabular == shapely
except NotImplementedError as e:
Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/ops/tests/test_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ....common import requires as _requires
from ....examples import get_path
from ....io import geotable as pdio
from ... import ops as GIS # noqa N812
from ... import ops as GIS # noqa: N812
from ...shapes import Polygon


Expand Down
8 changes: 4 additions & 4 deletions libpysal/cg/rtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def union_all(kids):
return cur


def Rtree(): # noqa N802
def Rtree(): # noqa: N802
return RTree()


Expand Down Expand Up @@ -416,7 +416,7 @@ class RTree:
>>> rt.intersection([5, 5, 6, 6])
[]
""" # noqa E501
""" # noqa: E501

def __init__(self):
self.count = 0
Expand Down Expand Up @@ -713,15 +713,15 @@ def walk(self, predicate):
def query_rect(self, r):
"""Yield objects that intersect with the rectangle (``r``)."""

def p(o, x): # noqa ARG001
def p(o, x): # noqa: ARG001
return r.does_intersect(o.rect)

yield from self.walk(p)

def query_point(self, point):
"""Yield objects that intersect with the point (``point``)."""

def p(o, x): # noqa ARG001
def p(o, x): # noqa: ARG001
return o.rect.does_containpoint(point)

yield from self.walk(p)
Expand Down
14 changes: 7 additions & 7 deletions libpysal/cg/segmentLocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def add(self, segment, id):
res = self.res
line = segment.line
tiny = res / 1000.0
for i in range(1 + min(i, I_), max(i, I_)): # noqa B020
for i in range(1 + min(i, I_), max(i, I_)): # noqa: B020
# print 'i',i
x = self.x_range[0] + (i * res)
y = line.y(x)
self.bin_loc((x - tiny, y), id)
self.bin_loc((x + tiny, y), id)
for j in range(1 + min(j, J_), max(j, J_)): # noqa B020
for j in range(1 + min(j, J_), max(j, J_)): # noqa: B020
# print 'j',j
y = self.y_range[0] + (j * res)
x = line.x(y)
Expand All @@ -226,7 +226,7 @@ def add(self, segment, id):
self._kd2 = None
return True

def remove(self, segment): # noqa ARG002
def remove(self, segment): # noqa: ARG002
self._kd = None
self._kd2 = None
pass
Expand Down Expand Up @@ -311,7 +311,7 @@ def nearest(self, pt):
cols[idx],
) # (i,j)'s of the filled grid cells within radius.

for t in zip(rows, cols): # noqa B905
for t in zip(rows, cols): # noqa: B905
possibles.update(self.hash[t])

if DEBUG:
Expand Down Expand Up @@ -361,7 +361,7 @@ def combo_check(bins, segments, qpoints):
DEBUG = False


def brute_check(segments, qpoints): # noqa ARG001
def brute_check(segments, qpoints): # noqa: ARG001
t0 = time.time()
G2 = BruteSegmentLocator(segs)
t1 = time.time()
Expand All @@ -379,7 +379,7 @@ def grid_check(bins, segments, qpoints, visualize=False):
t0 = time.time()
G = SegmentLocator(segments, bins)
t1 = time.time()
G.grid.kd # noqa B018
G.grid.kd # noqa: B018

Check warning on line 382 in libpysal/cg/segmentLocator.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/segmentLocator.py#L382

Added line #L382 was not covered by tests
t2 = time.time()
print("Created Grid in %0.4f seconds" % (t1 - t0))
print("Created KDTree in %0.4f seconds" % (t2 - t1))
Expand Down Expand Up @@ -415,7 +415,7 @@ def binSizeTest():
qpts = random_points(q)
for col, bins in enumerate(binSizes):
print("N, Bins:", n, bins)
qps = test_grid(bins, segs, qpts) # noqa F821
qps = test_grid(bins, segs, qpts) # noqa: F821

Check warning on line 418 in libpysal/cg/segmentLocator.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/segmentLocator.py#L418

Added line #L418 was not covered by tests
results[row, col] = qps
return results

Expand Down
8 changes: 4 additions & 4 deletions libpysal/cg/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def __init__(self, x):
self.m = float("inf")
self.b = float("nan")

def x(self, y) -> float: # noqa ARG002
def x(self, y) -> float: # noqa: ARG002
"""Returns the :math:`x`-value of the line at a particular :math:`y`-value.
Parameters
Expand All @@ -777,7 +777,7 @@ def x(self, y) -> float: # noqa ARG002

return self._x

def y(self, x) -> float: # noqa ARG002
def y(self, x) -> float: # noqa: ARG002
"""Returns the :math:`y`-value of the line at a particular :math:`x`-value.
Parameters
Expand Down Expand Up @@ -1642,7 +1642,7 @@ def part_area(pv: list) -> float:
__area += (pv[i][0] + pv[i + 1][0]) * (pv[i][1] - pv[i + 1][1])
__area = __area * 0.5
if __area < 0:
__area = -area # noqa F821
__area = -area # noqa: F821

Check warning on line 1645 in libpysal/cg/shapes.py

View check run for this annotation

Codecov / codecov/patch

libpysal/cg/shapes.py#L1645

Added line #L1645 was not covered by tests
return __area

sum_area = lambda part_type: sum([part_area(part) for part in part_type])
Expand Down Expand Up @@ -1956,7 +1956,7 @@ def height(self) -> Union[int, float]:
return self.upper - self.lower


_geoJSON_type_to_Pysal_type = { # noqa N816
_geoJSON_type_to_Pysal_type = { # noqa: N816
"point": Point,
"linestring": Chain,
"multilinestring": Chain,
Expand Down
4 changes: 2 additions & 2 deletions libpysal/cg/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def linear2arcdist(linear_dist, radius=RADIUS_EARTH_KM):
return arc_dist


def toXYZ(pt): # noqa N802
def toXYZ(pt): # noqa: N802
"""Convert a point's latitude and longitude to x,y,z.
Parameters
Expand All @@ -190,7 +190,7 @@ def toXYZ(pt): # noqa N802
return x, y, z


def toLngLat(xyz): # noqa N802
def toLngLat(xyz): # noqa: N802
"""Convert a point's x,y,z to latitude and longitude.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions libpysal/cg/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def get_rectangle_rectangle_intersection(r0, r1, checkOverlap=True):
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:] == r1[:]
True
""" # noqa E501
""" # noqa: E501

intersection = None
common_bb = True
Expand Down Expand Up @@ -634,7 +634,7 @@ def get_polygon_point_dist(poly, pt):
part_prox = []
for vertices in poly._vertices:
vx_range = range(-1, len(vertices) - 1)
seg = lambda i: LineSegment(vertices[i], vertices[i + 1]) # noqa B023
seg = lambda i: LineSegment(vertices[i], vertices[i + 1]) # noqa: B023
_min_dist = min([get_segment_point_dist(seg(i), pt)[0] for i in vx_range])
part_prox.append(_min_dist)
dist = min(part_prox)
Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/tests/test_geoJSON.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ... import examples as pysal_examples
from ...io.fileio import FileIO as psopen # noqa N813
from ...io.fileio import FileIO as psopen # noqa: N813
from ..shapes import Chain, Point, asShape


Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/tests/test_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from ... import examples as pysal_examples
from ...io.fileio import FileIO as psopen # noqa N813
from ...io.fileio import FileIO as psopen # noqa: N813
from .. import sphere


Expand Down
2 changes: 1 addition & 1 deletion libpysal/cg/voronoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def voronoi_frames(points, radius=None, clip="extent"):
>>> regions_df.shape == points_df.shape
True
""" # noqa E501
""" # noqa: E501

regions, vertices = voronoi(points, radius=radius)
regions, vertices = as_dataframes(regions, vertices, points)
Expand Down
2 changes: 1 addition & 1 deletion libpysal/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fetch_all():
example = datasets[name]
try:
example.download()
except: # noqa E722
except: # noqa: E722

Check warning on line 44 in libpysal/examples/__init__.py

View check run for this annotation

Codecov / codecov/patch

libpysal/examples/__init__.py#L44

Added line #L44 was not covered by tests
print(f"Example not downloaded: {name}")
example_manager.add_examples(datasets)

Expand Down
8 changes: 4 additions & 4 deletions libpysal/examples/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def type_of_script() -> str:
"""Helper function to determine run context."""

try:
ipy_str = str(type(get_ipython())) # noqa F821
ipy_str = str(type(get_ipython())) # noqa: F821

Check warning on line 89 in libpysal/examples/base.py

View check run for this annotation

Codecov / codecov/patch

libpysal/examples/base.py#L89

Added line #L89 was not covered by tests
if "zmqshell" in ipy_str:
return "jupyter"
if "terminal" in ipy_str:
Expand Down Expand Up @@ -217,7 +217,7 @@ def load(self, file_name) -> io.FileIO:
class Examples:
"""Manager for pysal example datasets."""

def __init__(self, datasets={}): # noqa B006
def __init__(self, datasets={}): # noqa: B006
self.datasets = datasets

def add_examples(self, examples):
Expand Down Expand Up @@ -269,7 +269,7 @@ def download_remotes(self):
example = self.remotes[name]
try:
example.download()
except: # noqa E722
except: # noqa: E722

Check warning on line 272 in libpysal/examples/base.py

View check run for this annotation

Codecov / codecov/patch

libpysal/examples/base.py#L272

Added line #L272 was not covered by tests
print(f"Example not downloaded: {name}.")

def get_installed_names(self) -> list:
Expand All @@ -281,7 +281,7 @@ def get_remote_url(self, name):
if name in self.datasets:
try:
return self.datasets[name].download_url
except: # noqa E722
except: # noqa: E722
print(f"{name} is a built-in dataset, no url.")
else:
print(f"{name} is not an available dataset.")
Expand Down
4 changes: 2 additions & 2 deletions libpysal/examples/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ def _remote_data():
url = "https://geodacenter.github.io/data-and-lab//"
try:
page = requests.get(url)
except: # noqa E722
warnings.warn("Remote data sets not available. Check connection.") # noqa B028
except: # noqa: E722
warnings.warn("Remote data sets not available. Check connection.") # noqa: B028

Check warning on line 648 in libpysal/examples/remotes.py

View check run for this annotation

Codecov / codecov/patch

libpysal/examples/remotes.py#L647-L648

Added lines #L647 - L648 were not covered by tests
return {}
soup = BeautifulSoup(page.text, "html.parser")
samples = soup.find(class_="samples")
Expand Down
2 changes: 1 addition & 1 deletion libpysal/examples/tests/test_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_data_home(self):
def test_data_home_fallback(self, path_exists_mock, makedirs_mock):
data_home = user_data_dir("pysal", "pysal")

def makedirs_side_effect(path, exist_ok=False): # noqa ARG001
def makedirs_side_effect(path, exist_ok=False): # noqa: ARG001
if path == data_home:
raise OSError(errno.EROFS)

Expand Down
2 changes: 1 addition & 1 deletion libpysal/graph/_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)

try:
from numba import njit # noqa E401
from numba import njit # noqa: E401

HAS_NUMBA = True
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion libpysal/graph/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _build_coincidence_lookup(geoms):
"""
Identify coincident points and create a look-up table for the coincident geometries.
"""
valid_coincident_geom_types = set(("Point",)) # noqa C405
valid_coincident_geom_types = set(("Point",)) # noqa: C405
if not set(geoms.geom_type) <= valid_coincident_geom_types:
raise ValueError(
"coindicence checks are only well-defined for "
Expand Down
4 changes: 2 additions & 2 deletions libpysal/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def adjacency(self):
return self._adjacency.copy()

@classmethod
def from_W(cls, w): # noqa N802
def from_W(cls, w): # noqa: N802
"""Create an experimental Graph from libpysal.weights.W object
Parameters
Expand All @@ -179,7 +179,7 @@ def from_W(cls, w): # noqa N802
"""
return cls.from_weights_dict(dict(w))

def to_W(self): # noqa N802
def to_W(self): # noqa: N802
"""Convert Graph to a libpysal.weights.W object
Returns
Expand Down
Loading

0 comments on commit 9b86f6d

Please sign in to comment.