Skip to content

Commit

Permalink
CI/TST: fix test, rm log action, ruff-format (#533)
Browse files Browse the repository at this point in the history
* CI/TST: fix test, rm log action

* resolve #531

* ruff all the way

* format

* Update momepy/preprocessing.py

Co-authored-by: James Gaboardi <[email protected]>

---------

Co-authored-by: James Gaboardi <[email protected]>
  • Loading branch information
martinfleis and jGaboardi authored Jan 9, 2024
1 parent 295c21d commit 2051f4b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 28 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,4 @@ jobs:
run: |
ci/envs/test_user_guide.sh
- uses: codecov/codecov-action@v3

- name: Generate and publish the report
if: |
failure()
&& github.event_name != 'pull_request'
&& github.repository == 'pysal/momepy'
&& steps.run_tests.outcome == 'failure'
uses: xarray-contrib/issue-from-pytest-log@v1
with:
log-path: pytest-log.jsonl
- uses: codecov/codecov-action@v3
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
files: 'momepy\/'
repos:
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.9"
rev: "v0.1.11"
hooks:
- id: ruff
- id: ruff-format

ci:
autofix_prs: false
Expand Down
4 changes: 1 addition & 3 deletions momepy/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,9 +1113,7 @@ def __init__(
[gdf.unary_union]
).geoms, # get parts of the collection from polygonize
crs=gdf.crs,
).explode(
ignore_index=True
) # shoudln't be needed but doesn't hurt to ensure
).explode(ignore_index=True) # shouldn't be needed but doesn't hurt to ensure

# Store geometries as a GeoDataFrame
self.polygons = gpd.GeoDataFrame(geometry=polygons)
Expand Down
2 changes: 1 addition & 1 deletion momepy/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ class CentroidCorners:
--------
>>> ccd = momepy.CentroidCorners(buildings_df)
100%|██████████| 144/144 [00:00<00:00, 846.58it/s]
>>> buildings_df['ccd_means'] = ccd.means
>>> buildings_df['ccd_means'] = ccd.mean
>>> buildings_df['ccd_stdev'] = ccd.std
>>> buildings_df['ccd_means'][0]
15.961531913184833
Expand Down
17 changes: 14 additions & 3 deletions momepy/tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,20 @@ def test_erroroneous_geom(self):
x = np.mean([b[0], b[2]])
y = np.mean([b[1], b[3]])

df.loc[144] = [145, Polygon([(x, y), (x, y + 1), (x + 1, y)])]
df.loc[145] = [146, MultiPoint([(x, y), (x + 1, y)]).buffer(0.55)]
df.loc[146] = [147, affinity.rotate(df.geometry.iloc[0], 12)]
df = pd.concat(
[
df,
gpd.GeoDataFrame(
{"uID": [145, 146, 147]},
geometry=[
Polygon([(x, y), (x, y + 1), (x + 1, y)]),
MultiPoint([(x, y), (x + 1, y)]).buffer(0.55),
affinity.rotate(df.geometry.iloc[0], 12),
],
index=[144, 145, 146],
),
]
)

with pytest.warns(
UserWarning, match="Tessellation does not fully match buildings."
Expand Down
6 changes: 5 additions & 1 deletion momepy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def _dual_to_gdf(net):


def nx_to_gdf(
net, points=True, lines=True, spatial_weights=False, nodeID="nodeID" # noqa
net,
points=True,
lines=True,
spatial_weights=False,
nodeID="nodeID", # noqa: N803
):
"""
Convert a ``networkx.Graph`` to a LineString GeoDataFrame and Point GeoDataFrame.
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ include = ["momepy", "momepy.*"]
[tool.setuptools.package-data]
momepy = ["datasets/bubenec.gpkg", "datasets/tests.gpkg"]

[tool.black]
line-length = 88

[tool.ruff]
line-length = 88
select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"]
Expand Down

0 comments on commit 2051f4b

Please sign in to comment.