diff --git a/libpysal/cg/alpha_shapes.py b/libpysal/cg/alpha_shapes.py index 4f075219a..4ea9db72f 100644 --- a/libpysal/cg/alpha_shapes.py +++ b/libpysal/cg/alpha_shapes.py @@ -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 @@ -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 """ diff --git a/libpysal/cg/locators.py b/libpysal/cg/locators.py index 916e7fab8..4beb5aeec 100644 --- a/libpysal/cg/locators.py +++ b/libpysal/cg/locators.py @@ -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): diff --git a/libpysal/cg/ops/_accessors.py b/libpysal/cg/ops/_accessors.py index 26e97b88b..f4f5ac5ae 100644 --- a/libpysal/cg/ops/_accessors.py +++ b/libpysal/cg/ops/_accessors.py @@ -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 df[outcol] = outval return None return outval diff --git a/libpysal/cg/ops/_shapely.py b/libpysal/cg/ops/_shapely.py index a679f680f..66792288d 100644 --- a/libpysal/cg/ops/_shapely.py +++ b/libpysal/cg/ops/_shapely.py @@ -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 else: - out = _cascaded_union(df[geom_col].tolist()) # noqa F821 + out = _cascaded_union(df[geom_col].tolist()) # noqa: F821 return out diff --git a/libpysal/cg/ops/tabular.py b/libpysal/cg/ops/tabular.py index 6162b2783..ca994c471 100644 --- a/libpysal/cg/ops/tabular.py +++ b/libpysal/cg/ops/tabular.py @@ -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 diff --git a/libpysal/cg/ops/tests/test_shapely.py b/libpysal/cg/ops/tests/test_shapely.py index c1203a1aa..5ce4c8cf0 100644 --- a/libpysal/cg/ops/tests/test_shapely.py +++ b/libpysal/cg/ops/tests/test_shapely.py @@ -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 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 else: assert tabular == shapely except NotImplementedError as e: diff --git a/libpysal/cg/ops/tests/test_tabular.py b/libpysal/cg/ops/tests/test_tabular.py index f027f19d7..0b5393883 100644 --- a/libpysal/cg/ops/tests/test_tabular.py +++ b/libpysal/cg/ops/tests/test_tabular.py @@ -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 diff --git a/libpysal/cg/rtree.py b/libpysal/cg/rtree.py index 3b2143814..43967cba4 100644 --- a/libpysal/cg/rtree.py +++ b/libpysal/cg/rtree.py @@ -318,7 +318,7 @@ def union_all(kids): return cur -def Rtree(): # noqa N802 +def Rtree(): # noqa: N802 return RTree() @@ -416,7 +416,7 @@ class RTree: >>> rt.intersection([5, 5, 6, 6]) [] - """ # noqa E501 + """ # noqa: E501 def __init__(self): self.count = 0 @@ -713,7 +713,7 @@ 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) @@ -721,7 +721,7 @@ def p(o, x): # noqa ARG001 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) diff --git a/libpysal/cg/segmentLocator.py b/libpysal/cg/segmentLocator.py index 96cf052b1..94cfa6a88 100644 --- a/libpysal/cg/segmentLocator.py +++ b/libpysal/cg/segmentLocator.py @@ -228,7 +228,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 @@ -313,7 +313,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: @@ -363,7 +363,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() @@ -417,7 +417,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 results[row, col] = qps return results diff --git a/libpysal/cg/sphere.py b/libpysal/cg/sphere.py index 2ce6e292b..a5b959bc0 100644 --- a/libpysal/cg/sphere.py +++ b/libpysal/cg/sphere.py @@ -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 @@ -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 diff --git a/libpysal/cg/standalone.py b/libpysal/cg/standalone.py index 685d0a25b..f94088740 100644 --- a/libpysal/cg/standalone.py +++ b/libpysal/cg/standalone.py @@ -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 @@ -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) diff --git a/libpysal/cg/tests/test_sphere.py b/libpysal/cg/tests/test_sphere.py index 5a3a8ad65..539b52ee4 100644 --- a/libpysal/cg/tests/test_sphere.py +++ b/libpysal/cg/tests/test_sphere.py @@ -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 diff --git a/libpysal/cg/voronoi.py b/libpysal/cg/voronoi.py index c80b22f22..3abf4c0a7 100644 --- a/libpysal/cg/voronoi.py +++ b/libpysal/cg/voronoi.py @@ -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) diff --git a/libpysal/common.py b/libpysal/common.py index 64663e2bb..6285085f2 100644 --- a/libpysal/common.py +++ b/libpysal/common.py @@ -1,6 +1,6 @@ import copy -import pandas # noqa F401 +import pandas # noqa: F401 try: from patsy import PatsyError @@ -23,7 +23,7 @@ except ImportError: - def jit(function=None, **kwargs): # noqa ARG001 + def jit(function=None, **kwargs): # noqa: ARG001 """Mimic numba.jit() with synthetic wrapper.""" if function is not None: @@ -128,7 +128,7 @@ def inner(function): return function else: - def passer(*args, **kwargs): # noqa ARG001 + def passer(*args, **kwargs): # noqa: ARG001 if v: missing = [arg for i, arg in enumerate(wanted) if not available[i]] print(f"missing dependencies: {missing}") diff --git a/libpysal/examples/__init__.py b/libpysal/examples/__init__.py index bbf65dabf..822308c3f 100644 --- a/libpysal/examples/__init__.py +++ b/libpysal/examples/__init__.py @@ -41,7 +41,7 @@ def fetch_all(): example = datasets[name] try: example.download() - except: # noqa E722 + except: # noqa: E722 print(f"Example not downloaded: {name}") example_manager.add_examples(datasets) diff --git a/libpysal/examples/base.py b/libpysal/examples/base.py index d92da0148..949692160 100644 --- a/libpysal/examples/base.py +++ b/libpysal/examples/base.py @@ -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 if "zmqshell" in ipy_str: return "jupyter" if "terminal" in ipy_str: @@ -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): @@ -269,7 +269,7 @@ def download_remotes(self): example = self.remotes[name] try: example.download() - except: # noqa E722 + except: # noqa: E722 print(f"Example not downloaded: {name}.") def get_installed_names(self) -> list: @@ -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.") diff --git a/libpysal/examples/remotes.py b/libpysal/examples/remotes.py index 96dcad960..c9c078dc4 100644 --- a/libpysal/examples/remotes.py +++ b/libpysal/examples/remotes.py @@ -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 return {} soup = BeautifulSoup(page.text, "html.parser") samples = soup.find(class_="samples") diff --git a/libpysal/examples/tests/test_available.py b/libpysal/examples/tests/test_available.py index c5ee358c1..bf5213b83 100644 --- a/libpysal/examples/tests/test_available.py +++ b/libpysal/examples/tests/test_available.py @@ -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) diff --git a/libpysal/graph/_triangulation.py b/libpysal/graph/_triangulation.py index 076ce9a03..faa6ab3d2 100644 --- a/libpysal/graph/_triangulation.py +++ b/libpysal/graph/_triangulation.py @@ -19,7 +19,7 @@ ) try: - from numba import njit # noqa E401 + from numba import njit # noqa: E401 HAS_NUMBA = True except ModuleNotFoundError: diff --git a/libpysal/graph/_utils.py b/libpysal/graph/_utils.py index 748636f99..8cab2f674 100644 --- a/libpysal/graph/_utils.py +++ b/libpysal/graph/_utils.py @@ -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 " diff --git a/libpysal/graph/base.py b/libpysal/graph/base.py index 821806414..a52a23add 100644 --- a/libpysal/graph/base.py +++ b/libpysal/graph/base.py @@ -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 @@ -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 diff --git a/libpysal/graph/tests/test_set_ops.py b/libpysal/graph/tests/test_set_ops.py index e86b0ee40..8ac9cc3e4 100644 --- a/libpysal/graph/tests/test_set_ops.py +++ b/libpysal/graph/tests/test_set_ops.py @@ -97,10 +97,10 @@ def test___gt__(self): def test___eq__(self): assert self.distance2500 == self.distance2500.copy() - assert not self.distance2500 == self.distance2500_id # noqa SIM201 + assert not self.distance2500 == self.distance2500_id # noqa: SIM201 def test___ne__(self): - assert not self.distance2500 != self.distance2500.copy() # noqa SIM202 + assert not self.distance2500 != self.distance2500.copy() # noqa: SIM202 assert self.distance2500 != self.distance2500_id def test___and__(self): diff --git a/libpysal/io/__init__.py b/libpysal/io/__init__.py index fb22c31fb..873f1306f 100644 --- a/libpysal/io/__init__.py +++ b/libpysal/io/__init__.py @@ -3,4 +3,4 @@ from .tables import * from .util import * -open = fileio.FileIO # noqa A001 +open = fileio.FileIO # noqa: A001 diff --git a/libpysal/io/fileio.py b/libpysal/io/fileio.py index 1a167c62a..fa3f88b7a 100644 --- a/libpysal/io/fileio.py +++ b/libpysal/io/fileio.py @@ -146,7 +146,7 @@ def check(cls): print(f"Ext: '.{key}', Modes: {list(val.keys())!r}") @classmethod - def open(cls, *args, **kwargs): # noqa A001 + def open(cls, *args, **kwargs): # noqa: A001 """Alias for ``FileIO()``.""" return cls(*args, **kwargs) diff --git a/libpysal/io/iohandlers/__init__.py b/libpysal/io/iohandlers/__init__.py index e4595835a..a47210267 100644 --- a/libpysal/io/iohandlers/__init__.py +++ b/libpysal/io/iohandlers/__init__.py @@ -21,5 +21,5 @@ try: from . import db -except: # noqa E722 - warnings.warn("SQLAlchemy not installed, database I/O disabled") # noqa B028 +except: # noqa: E722 + warnings.warn("SQLAlchemy not installed, database I/O disabled") # noqa: B028 diff --git a/libpysal/io/iohandlers/arcgis_dbf.py b/libpysal/io/iohandlers/arcgis_dbf.py index 23584b5b8..18debe160 100644 --- a/libpysal/io/iohandlers/arcgis_dbf.py +++ b/libpysal/io/iohandlers/arcgis_dbf.py @@ -66,7 +66,7 @@ def _get_varName(self): varName = property(fget=_get_varName, fset=_set_varName) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 self._complain_ifclosed(self.closed) return self._read() diff --git a/libpysal/io/iohandlers/arcgis_swm.py b/libpysal/io/iohandlers/arcgis_swm.py index df2e457b3..149417457 100644 --- a/libpysal/io/iohandlers/arcgis_swm.py +++ b/libpysal/io/iohandlers/arcgis_swm.py @@ -41,7 +41,7 @@ class ArcGISSwmIO(fileio.FileIO): W_SUM_i l.e. float Sum of weights for " 8 ============ ============ ==================================== ================================ - """ # noqa E501 + """ # noqa: E501 FORMATS = ["swm"] MODES = ["r", "w"] @@ -70,7 +70,7 @@ def _get_srs(self): srs = property(fget=_get_srs, fset=_set_srs) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 self._complain_ifclosed(self.closed) return self._read() @@ -237,7 +237,7 @@ def read_new_version(self, header_line): return w - def write(self, obj, useIdIndex=False): # noqa N803 + def write(self, obj, useIdIndex=False): # noqa: N803 """Writes a spatial weights matrix data file in ``.swm`` format. Parameters diff --git a/libpysal/io/iohandlers/arcgis_txt.py b/libpysal/io/iohandlers/arcgis_txt.py index 2c27bc5bd..5196c8f52 100644 --- a/libpysal/io/iohandlers/arcgis_txt.py +++ b/libpysal/io/iohandlers/arcgis_txt.py @@ -132,7 +132,7 @@ def _read(self): msg = "DBF relating to ArcGIS TEXT was not found, " msg += "proceeding with unordered string IDs." warn(msg, RuntimeWarning, stacklevel=2) - except: # noqa E722 + except: # noqa: E722 msg = "Exception occurred will reading DBF, " msg += "proceeding with unordered string IDs." warn(msg, RuntimeWarning, stacklevel=2) @@ -159,7 +159,7 @@ def _read(self): return w - def write(self, obj, useIdIndex=False): # noqa N803 + def write(self, obj, useIdIndex=False): # noqa: N803 """ Parameters diff --git a/libpysal/io/iohandlers/csvWrapper.py b/libpysal/io/iohandlers/csvWrapper.py index a4f6b88f3..cf14d28c5 100644 --- a/libpysal/io/iohandlers/csvWrapper.py +++ b/libpysal/io/iohandlers/csvWrapper.py @@ -70,7 +70,7 @@ class csvWrapper(tables.DataTable): """ - __doc__ = tables.DataTable.__doc__ # noqa A003 + __doc__ = tables.DataTable.__doc__ # noqa: A003 FORMATS = ["csv"] READ_MODES = ["r", "Ur", "rU", "U"] MODES = READ_MODES[:] diff --git a/libpysal/io/iohandlers/gal.py b/libpysal/io/iohandlers/gal.py index 3176084d8..ca24c6493 100644 --- a/libpysal/io/iohandlers/gal.py +++ b/libpysal/io/iohandlers/gal.py @@ -21,7 +21,7 @@ def __init__(self, *args, **kwargs): fileio.FileIO.__init__(self, *args, **kwargs) self.file = open(self.dataPath, self.mode) - def read(self, n=-1, sparse=False): # noqa ARG002 + def read(self, n=-1, sparse=False): # noqa: ARG002 """Read in a ``.gal`` file. Parameters diff --git a/libpysal/io/iohandlers/geobugs_txt.py b/libpysal/io/iohandlers/geobugs_txt.py index d7562233b..8bd423f60 100644 --- a/libpysal/io/iohandlers/geobugs_txt.py +++ b/libpysal/io/iohandlers/geobugs_txt.py @@ -72,7 +72,7 @@ def __init__(self, *args, **kwargs): fileio.FileIO.__init__(self, *args, **kwargs) self.file = open(self.dataPath, self.mode) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 """Read a GeoBUGS text file. Returns diff --git a/libpysal/io/iohandlers/gwt.py b/libpysal/io/iohandlers/gwt.py index 888e6eb2b..d2a76918f 100644 --- a/libpysal/io/iohandlers/gwt.py +++ b/libpysal/io/iohandlers/gwt.py @@ -64,7 +64,7 @@ def _get_shpName(self) -> str: shpName = property(fget=_get_shpName, fset=_set_shpName) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 """ Parameters @@ -204,7 +204,7 @@ def _read(self): msg = "DBF relating to GWT was not found, " msg += "proceeding with unordered string IDs." warn(msg, RuntimeWarning, stacklevel=2) - except: # noqa E722 + except: # noqa: E722 msg = "Exception occurred will reading DBF, " msg += "proceeding with unordered string IDs." warn(msg, RuntimeWarning, stacklevel=2) diff --git a/libpysal/io/iohandlers/mat.py b/libpysal/io/iohandlers/mat.py index d849932a1..525f6e333 100644 --- a/libpysal/io/iohandlers/mat.py +++ b/libpysal/io/iohandlers/mat.py @@ -51,7 +51,7 @@ def _get_varName(self) -> str: varName = property(fget=_get_varName, fset=_set_varName) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 """ Parameters diff --git a/libpysal/io/iohandlers/mtx.py b/libpysal/io/iohandlers/mtx.py index c7eda9c7f..87565c884 100644 --- a/libpysal/io/iohandlers/mtx.py +++ b/libpysal/io/iohandlers/mtx.py @@ -59,7 +59,7 @@ def __init__(self, *args, **kwargs): fileio.FileIO.__init__(self, *args, **kwargs) self.file = open(self.dataPath, self.mode + "b") - def read(self, n=-1, sparse=False): # noqa ARG002 + def read(self, n=-1, sparse=False): # noqa: ARG002 """ Parameters diff --git a/libpysal/io/iohandlers/stata_txt.py b/libpysal/io/iohandlers/stata_txt.py index 8be9e7954..9a94f6480 100644 --- a/libpysal/io/iohandlers/stata_txt.py +++ b/libpysal/io/iohandlers/stata_txt.py @@ -67,7 +67,7 @@ class StataTextIO(fileio.FileIO): matrix object in STATA. However, all those notes are lost when the matrix is exported. PySAL also does not take care of those notes. - """ # noqa E501 + """ # noqa: E501 FORMATS = ["stata_text"] MODES = ["r", "w"] @@ -77,7 +77,7 @@ def __init__(self, *args, **kwargs): fileio.FileIO.__init__(self, *args, **kwargs) self.file = open(self.dataPath, self.mode) - def read(self, n=-1): # noqa ARG002 + def read(self, n=-1): # noqa: ARG002 """ Parameters diff --git a/libpysal/io/iohandlers/wk1.py b/libpysal/io/iohandlers/wk1.py index 6a5da4e6f..33ca16755 100644 --- a/libpysal/io/iohandlers/wk1.py +++ b/libpysal/io/iohandlers/wk1.py @@ -135,7 +135,7 @@ class Wk1IO(fileio.FileIO): | [EOF] |End of file |unsigned short |4 |1,0,0,0 | +-------------+---------------------+-------------------------+-------+-----------------------------+ - """ # noqa E501 + """ # noqa: E501 FORMATS = ["wk1"] MODES = ["r", "w"] @@ -152,7 +152,7 @@ def _set_varName(self, val): def _get_varName(self) -> str: return self._varName - varName = property(fget=_get_varName, fset=_set_varName) # noqa N815 + varName = property(fget=_get_varName, fset=_set_varName) # noqa: N815 def read(self, n=-1): """ diff --git a/libpysal/io/iohandlers/wkt.py b/libpysal/io/iohandlers/wkt.py index 8ff33befe..d8e729fc7 100644 --- a/libpysal/io/iohandlers/wkt.py +++ b/libpysal/io/iohandlers/wkt.py @@ -51,7 +51,7 @@ def __init__(self, *args, **kwargs): self.__pos = 0 self.__open() - def open(self): # noqa A003 + def open(self): # noqa: A003 self.__open() def __open(self): diff --git a/libpysal/io/tables.py b/libpysal/io/tables.py index d6f93fac2..af0928915 100644 --- a/libpysal/io/tables.py +++ b/libpysal/io/tables.py @@ -16,7 +16,7 @@ class DataTable(fileio.FileIO): tables should subclass this instead of `FileIO`. """ - class _By_Col: # noqa N801 + class _By_Col: # noqa: N801 def __init__(self, parent): self.p = parent diff --git a/libpysal/io/util/shapefile.py b/libpysal/io/util/shapefile.py index 16599e090..6fd2daecf 100644 --- a/libpysal/io/util/shapefile.py +++ b/libpysal/io/util/shapefile.py @@ -440,7 +440,7 @@ def __len__(self) -> int: def __iter__(self): return self - def type(self) -> str: # noqa A003 + def type(self) -> str: # noqa: A003 return self.shape.String_Type def __next__(self) -> int: @@ -800,7 +800,7 @@ class NullShape: def unpack(self) -> None: return None - def pack(self, x=None) -> str: # noqa ARG002 + def pack(self, x=None) -> str: # noqa: ARG002 return pack(">> kqd.weights {0: [1.0, 0.35206533556593145, 0.3412334260702758], 1: [0.35206533556593145, 1.0, 0.2419707487162134, 0.3412334260702758, 0.31069657591175387], 2: [0.2419707487162134, 1.0, 0.31069657591175387], 3: [0.3412334260702758, 0.3412334260702758, 1.0, 0.3011374490937829, 0.26575287272131043], 4: [0.31069657591175387, 0.31069657591175387, 0.3011374490937829, 1.0, 0.35206533556593145], 5: [0.26575287272131043, 0.35206533556593145, 1.0]} - """ # noqa E501 + """ # noqa: E501 def __init__( self, @@ -549,7 +549,7 @@ def __init__( try: bandwidth = np.array(bandwidth) bandwidth.shape = (len(bandwidth), 1) - except: # noqa E722 + except: # noqa: E722 bandwidth = np.ones((len(data), 1), "float") * bandwidth self.bandwidth = bandwidth else: @@ -833,7 +833,7 @@ def __init__( data, distance_metric=distance_metric, radius=radius ) self.data = self.kdtree.data - except: # noqa E722 + except: # noqa: E722 raise ValueError("Could not make array from data") from None else: self.data = data diff --git a/libpysal/weights/gabriel.py b/libpysal/weights/gabriel.py index 3402b27bc..fe0920c0a 100644 --- a/libpysal/weights/gabriel.py +++ b/libpysal/weights/gabriel.py @@ -55,7 +55,7 @@ class Delaunay(W): def __init__(self, coordinates, **kwargs): try: - from numba import njit # noqa F401 + from numba import njit # noqa: F401 except ModuleNotFoundError: warnings.warn( "The numba package is used extensively in this module" @@ -178,7 +178,7 @@ class Gabriel(Delaunay): def __init__(self, coordinates, **kwargs): try: - from numba import njit # noqa F401 + from numba import njit # noqa: F401 except ModuleNotFoundError: warnings.warn( "The numba package is used extensively in this module" @@ -204,7 +204,7 @@ def __init__(self, coordinates, **kwargs): W.__init__(self, gabriel_neighbors, id_order=list(ids), **kwargs) -class Relative_Neighborhood(Delaunay): # noqa N801 +class Relative_Neighborhood(Delaunay): # noqa: N801 """ Constructs the Relative Neighborhood graph from a set of points. This graph is a subset of the Delaunay triangulation, where only @@ -228,7 +228,7 @@ class Relative_Neighborhood(Delaunay): # noqa N801 def __init__(self, coordinates, binary=True, **kwargs): try: - from numba import njit # noqa F401 + from numba import njit # noqa: F401 except ModuleNotFoundError: warnings.warn( "The numba package is used extensively in this module" diff --git a/libpysal/weights/raster.py b/libpysal/weights/raster.py index 7c4f572be..ec785038f 100644 --- a/libpysal/weights/raster.py +++ b/libpysal/weights/raster.py @@ -12,12 +12,12 @@ if os.path.basename(sys.argv[0]) in ("pytest", "py.test"): - def jit(*dec_args, **dec_kwargs): # noqa ARG001 + def jit(*dec_args, **dec_kwargs): # noqa: ARG001 """ decorator mimicking numba.jit """ - def intercepted_function(f, *f_args, **f_kwargs): # noqa ARG001 + def intercepted_function(f, *f_args, **f_kwargs): # noqa: ARG001 return f return intercepted_function @@ -243,7 +243,7 @@ def da2WSP( n = len(ids) try: - import numba # noqa F401 + import numba # noqa: F401 except (ModuleNotFoundError, ImportError): warn( "numba cannot be imported, parallel processing " @@ -263,7 +263,7 @@ def da2WSP( if n_jobs != 1: try: - import joblib # noqa F401 + import joblib # noqa: F401 except (ModuleNotFoundError, ImportError): warn( f"Parallel processing is requested (n_jobs={n_jobs})," @@ -565,7 +565,7 @@ def _index2da(data, index, attrs, coords): else: min_data = np.min(data) fill_value = min_data - 1 if min_data < 0 else -1 - attrs["nodatavals"] = tuple([fill_value]) # noqa C409 + attrs["nodatavals"] = tuple([fill_value]) # noqa: C409 data_complete = np.full(shape, fill_value, data.dtype) else: data_complete = np.empty(shape, data.dtype) diff --git a/libpysal/weights/set_operations.py b/libpysal/weights/set_operations.py index ee8a7a369..2bf3d6037 100644 --- a/libpysal/weights/set_operations.py +++ b/libpysal/weights/set_operations.py @@ -386,7 +386,7 @@ def w_subset(w1, ids, **kwargs): return W(neighbors, id_order=list(ids), **kwargs) -def w_clip(w1, w2, outSP=True, **kwargs): # noqa N803 +def w_clip(w1, w2, outSP=True, **kwargs): # noqa: N803 """ Clip a continuous W object (w1) with a different W object (w2) so only cells where w2 has a non-zero value remain with non-zero values in w1. diff --git a/libpysal/weights/spatial_lag.py b/libpysal/weights/spatial_lag.py index 9b2731906..ea708bf1f 100644 --- a/libpysal/weights/spatial_lag.py +++ b/libpysal/weights/spatial_lag.py @@ -153,7 +153,7 @@ def lag_categorical(w, y, ties="tryself"): >>> check = np.array([['b', 'd'], ['a', 'c'], ['b', 'c'], ['c', 'd'], ['b', 'd'], ['c', 'c'], ['b', 'd'], ['c', 'd'], ['b', 'c']]) >>> np.array_equal(check, ym_lag) True - """ # noqa E501 + """ # noqa: E501 if isinstance(y, list): y = np.array(y) orig_shape = y.shape diff --git a/libpysal/weights/spintW.py b/libpysal/weights/spintW.py index c3f13f994..ad9fb80de 100644 --- a/libpysal/weights/spintW.py +++ b/libpysal/weights/spintW.py @@ -54,7 +54,7 @@ def ODW(Wo, Wd, transform="r", silence_warnings=True): if Wo.transform != "b": try: Wo.tranform = "b" - except: # noqa E722 + except: # noqa: E722 raise AttributeError( "Wo is not binary and cannot be transformed to " "binary. Wo must be binary or suitably transformed to binary." @@ -62,7 +62,7 @@ def ODW(Wo, Wd, transform="r", silence_warnings=True): if Wd.transform != "b": try: Wd.tranform = "b" - except: # noqa E722 + except: # noqa: E722 raise AttributeError( "Wd is not binary and cannot be transformed to " "binary. Wd must be binary or suitably transformed to binary." @@ -168,7 +168,7 @@ def vecW( alpha=-1.0, binary=True, ids=None, - build_sp=False, # noqa ARG001 + build_sp=False, # noqa: ARG001 **kwargs, ): """ diff --git a/libpysal/weights/tests/test__contW_lists.py b/libpysal/weights/tests/test__contW_lists.py index 802b7b9aa..269c99bbe 100644 --- a/libpysal/weights/tests/test__contW_lists.py +++ b/libpysal/weights/tests/test__contW_lists.py @@ -106,7 +106,7 @@ def test_shapely(self): shplyneighbs = ContiguityWeightsLists(gdf.geometry.tolist(), QUEEN) assert pysalneighbs.w == shplyneighbs.w - def build_w(self, shapefile, type_, idVariable=None): # noqa N803 + def build_w(self, shapefile, type_, idVariable=None): # noqa: N803 """Building 2 W's the hard way. We need to do this so we can test both rtree and binning """ diff --git a/libpysal/weights/tests/test_adjlist.py b/libpysal/weights/tests/test_adjlist.py index 3706a72b4..3b8882a6e 100644 --- a/libpysal/weights/tests/test_adjlist.py +++ b/libpysal/weights/tests/test_adjlist.py @@ -97,7 +97,7 @@ def test_mvapply(self): df = geopandas.read_file(examples.get_path("columbus.dbf")).head() w = weights.Queen.from_dataframe(df) - ssq = lambda x_y: np.sum((x_y[0] - x_y[1]) ** 2).item() # noqa E731 + ssq = lambda x_y: np.sum((x_y[0] - x_y[1]) ** 2).item() # noqa: E731 ssq.__name__ = "sum_of_squares" alist = adj.adjlist_apply( df[["HOVAL", "CRIME", "INC"]], diff --git a/libpysal/weights/user.py b/libpysal/weights/user.py index c732d2920..e1dd4df53 100644 --- a/libpysal/weights/user.py +++ b/libpysal/weights/user.py @@ -99,7 +99,7 @@ def min_threshold_dist_from_shapefile(shapefile, radius=None, p=2): return min_threshold_distance(points, p) -def build_lattice_shapefile(nrows, ncols, outFileName): # noqa N803 +def build_lattice_shapefile(nrows, ncols, outFileName): # noqa: N803 """ Build a lattice shapefile with nrows rows and ncols cols. diff --git a/libpysal/weights/util.py b/libpysal/weights/util.py index 136a49d71..997f136f4 100644 --- a/libpysal/weights/util.py +++ b/libpysal/weights/util.py @@ -284,7 +284,7 @@ def block_weights(regimes, ids=None, sparse=False, **kwargs): >>> w = block_weights(regimes) >>> w.neighbors == {0: [1], 1: [0], 2: [3], 3: [2], 4: [5, 8], 5: [4, 8], 6: [7], 7: [6], 8: [4, 5]} True - """ # noqa E501 + """ # noqa: E501 rids = np.unique(regimes) neighbors = {} npnz = np.nonzero @@ -899,7 +899,7 @@ def fill_diagonal(w, val=1.0, wsp=False): return WSP2W(w_out) -def remap_ids(w, old2new, id_order=[], **kwargs): # noqa B006 +def remap_ids(w, old2new, id_order=[], **kwargs): # noqa: B006 """ Remaps the IDs in a spatial weights object. @@ -1301,7 +1301,7 @@ def isKDTree(obj): This is a utility function to determine whether or not an object is a KDTree, since KDTree and cKDTree have no common parent type """ - return any([issubclass(type(obj), KDTYPE) for KDTYPE in KDTREE_TYPES]) # noqa C419 + return any([issubclass(type(obj), KDTYPE) for KDTYPE in KDTREE_TYPES]) # noqa: C419 def attach_islands(w, w_knn1, **kwargs): @@ -1423,7 +1423,7 @@ def nonplanar_neighbors(w, geodataframe, tolerance=0.001, **kwargs): ---------- Planar Enforcement: http://ibis.geog.ubc.ca/courses/klink/gis.notes/ncgia/u12.html#SEC12.6 - """ # noqa E501 + """ # noqa: E501 gdf = geodataframe assert gdf.sindex, ( diff --git a/libpysal/weights/weights.py b/libpysal/weights/weights.py index 408694124..f24141769 100644 --- a/libpysal/weights/weights.py +++ b/libpysal/weights/weights.py @@ -182,7 +182,7 @@ class W: UserWarning: The weights matrix is not fully connected: There are 3 disconnected components. There are 2 islands with ids: 2, 3. - """ # noqa E501 + """ # noqa: E501 def __init__( self, @@ -190,7 +190,7 @@ def __init__( weights=None, id_order=None, silence_warnings=False, - ids=None, # noqa ARG002 + ids=None, # noqa: ARG002 ): self.silence_warnings = silence_warnings self.transformations = {} @@ -232,7 +232,7 @@ def _reset(self): """Reset properties.""" self._cache = {} - def to_file(self, path="", format=None): # noqa A002 + def to_file(self, path="", format=None): # noqa: A002 """ Write a weights to a file. The format is guessed automatically from the path, but can be overridden with the format argument. @@ -255,7 +255,7 @@ def to_file(self, path="", format=None): # noqa A002 f.close() @classmethod - def from_file(cls, path="", format=None): # noqa A002 + def from_file(cls, path="", format=None): # noqa: A002 """ Read a weights file into a W object. @@ -478,7 +478,7 @@ def to_networkx(self): return nx.from_scipy_sparse_array(self.sparse, create_using=g) @classmethod - def from_networkx(cls, graph, weight_col="weight"): # noqa ARG003 + def from_networkx(cls, graph, weight_col="weight"): # noqa: ARG003 """Convert a ``networkx`` graph to a PySAL ``W`` object. Parameters @@ -1261,7 +1261,7 @@ def asymmetry(self, intrinsic=True): >>> w=W(neighbors,weights) >>> w.asymmetry() [(0, 1), (1, 0)] - """ # noqa E501 + """ # noqa: E501 if intrinsic: wd = self.sparse.transpose() - self.sparse