Skip to content

Commit

Permalink
[SEDONA-390] Add codespell with pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jbampton committed Sep 9, 2023
1 parent d58baa8 commit 6e8a77d
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 42 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on: [pull_request]

permissions:
contents: read

jobs:
pre-commit:
name: Run pre-commit # https://pre-commit.com/
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- uses: actions/setup-python@v4 # https://www.python.org/
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install dependencies # https://pip.pypa.io/en/stable/
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# https://pre-commit.com/#installation
default_stages: [commit, push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
minimum_pre_commit_version: '2.18.1'
repos:
- repo: meta
hooks:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
name: Run codespell
description: Check spelling with codespell
entry: codespell --ignore-words=codespell.txt
exclude: ^docs/image|^spark/common/src/test/resources/points\.csv$
2 changes: 1 addition & 1 deletion binder/Sedona_OvertureMaps_GeoParquet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"source": [
"### Visualizing Overture Maps\n",
"\n",
"Explanation to the each step is similar accross the different datasets. [Click here to learn more about Overture Maps.](https://docs.overturemaps.org)\n",
"Explanation to the each step is similar across the different datasets. [Click here to learn more about Overture Maps.](https://docs.overturemaps.org)\n",
"\n",
"1. `df = sedona.read.format(\"geoparquet\").load(DATA_LINK+\"theme=XX/type=YY\")`\n",
"\n",
Expand Down
14 changes: 14 additions & 0 deletions codespell.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
actualy
afterall
bu
eiter
fpt
limite
nd
ois
parm
pixelx
refere
ser
shouldbe
wel
44 changes: 22 additions & 22 deletions common/src/test/java/org/apache/sedona/common/FunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,29 @@ public void asEWKT() throws Exception{
Geometry geometry = geometryFactory.createPoint(new Coordinate(1.0, 2.0));
String actualResult = Functions.asEWKT(geometry);
String expectedResult = "SRID=4236;POINT (1 2)";
Geometry acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
Geometry actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = geometryFactory.createPoint(new Coordinate(1.0, 2.0, 3.0));
actualResult = Functions.asEWKT(geometry);
expectedResult = "SRID=4236;POINT Z(1 2 3)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = geometryFactory.createPoint(new CoordinateXYM(1.0, 2.0, 3.0));
actualResult = Functions.asEWKT(geometry);
expectedResult = "SRID=4236;POINT M(1 2 3)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = geometryFactory.createPoint(new CoordinateXYZM(1.0, 2.0, 3.0, 4.0));
actualResult = Functions.asEWKT(geometry);
expectedResult = "SRID=4236;POINT ZM(1 2 3 4)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);
}

Expand All @@ -107,29 +107,29 @@ public void asWKT() throws Exception {
Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
String actualResult = Functions.asWKT(geometry);
String expectedResult = "POINT (1 2)";
Geometry acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
Geometry actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0, 3.0));
actualResult = Functions.asWKT(geometry);
expectedResult = "POINT Z(1 2 3)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = GEOMETRY_FACTORY.createPoint(new CoordinateXYM(1.0, 2.0, 3.0));
actualResult = Functions.asWKT(geometry);
expectedResult = "POINT M(1 2 3)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);

geometry = GEOMETRY_FACTORY.createPoint(new CoordinateXYZM(1.0, 2.0, 3.0, 4.0));
actualResult = Functions.asWKT(geometry);
expectedResult = "POINT ZM(1 2 3 4)";
acutal = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, acutal);
actual = Constructors.geomFromEWKT(expectedResult);
assertEquals(geometry, actual);
assertEquals(expectedResult, actualResult);
}

Expand Down Expand Up @@ -942,22 +942,22 @@ public void makeLine3d() {
WKTWriter wktWriter3D = new WKTWriter(3);
Point point1 = GEOMETRY_FACTORY.createPoint(new Coordinate(1, 1, 1));
Point point2 = GEOMETRY_FACTORY.createPoint(new Coordinate(2, 2, 2));
LineString acutalLinestring = (LineString) Functions.makeLine(point1, point2);
LineString actualLinestring = (LineString) Functions.makeLine(point1, point2);
LineString expectedLineString = GEOMETRY_FACTORY.createLineString(coordArray3d( 1, 1, 1, 2, 2, 2));
assertEquals(wktWriter3D.write(acutalLinestring), wktWriter3D.write(expectedLineString));
assertEquals(wktWriter3D.write(actualLinestring), wktWriter3D.write(expectedLineString));

MultiPoint multiPoint1 = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray3d(0.5, 0.5, 1, 1, 1, 1));
MultiPoint multiPoint2 = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray3d(0.5, 0.5, 2, 2, 2, 2));
acutalLinestring = (LineString) Functions.makeLine(multiPoint1, multiPoint2);
actualLinestring = (LineString) Functions.makeLine(multiPoint1, multiPoint2);
expectedLineString = GEOMETRY_FACTORY.createLineString(coordArray3d( 0.5, 0.5, 1, 1, 1, 1, 0.5, 0.5, 2, 2, 2, 2));
assertEquals(wktWriter3D.write(acutalLinestring), wktWriter3D.write(expectedLineString));
assertEquals(wktWriter3D.write(actualLinestring), wktWriter3D.write(expectedLineString));

LineString line1 = GEOMETRY_FACTORY.createLineString(coordArray3d(0, 0, 1, 1, 1, 1));
LineString line2 = GEOMETRY_FACTORY.createLineString(coordArray3d(2, 2, 2, 2, 3, 3));
Geometry[] geoms = new Geometry[]{line1, line2};
acutalLinestring = (LineString) Functions.makeLine(geoms);
actualLinestring = (LineString) Functions.makeLine(geoms);
expectedLineString = GEOMETRY_FACTORY.createLineString(coordArray3d( 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3));
assertEquals(wktWriter3D.write(acutalLinestring), wktWriter3D.write(expectedLineString));
assertEquals(wktWriter3D.write(actualLinestring), wktWriter3D.write(expectedLineString));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testNoDataValueUsingComplexCategoryList() {
Assert.assertNull(band5.getCategory(10));
Assert.assertEquals("GrayScale", band5.getCategory(100).getName().toString());

// If the new no data value falls within the range of an existing quantitative category, the category is splitted
// If the new no data value falls within the range of an existing quantitative category, the category is split
// into two categories.
GridSampleDimension band6 = RasterUtils.createSampleDimensionWithNoDataValue(band, 150);
Assert.assertEquals(150, RasterUtils.getNoDataValue(band6), 1e-9);
Expand Down
2 changes: 1 addition & 1 deletion docs/api/flink/Function.md
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ LINESTRING EMPTY

## ST_FrechetDistance

Introduction: Computes and returns discrete [Frechet Distance](https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance) between the given two geometrie,
Introduction: Computes and returns discrete [Frechet Distance](https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance) between the given two geometries,
based on [Computing Discrete Frechet Distance](http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf)

If any of the geometries is empty, returns 0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/api/sql/Function.md
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ LINESTRING EMPTY

## ST_FrechetDistance

Introduction: Computes and returns discrete [Frechet Distance](https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance) between the given two geometrie,
Introduction: Computes and returns discrete [Frechet Distance](https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance) between the given two geometries,
based on [Computing Discrete Frechet Distance](http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf)

If any of the geometries is empty, returns 0.0
Expand Down
6 changes: 3 additions & 3 deletions docs/setup/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Sedona 1.4.1 is compiled against, Spark 3.3 / Spark 3.4 / Flink 1.12, Java 8.
* [X] **Sedona Spark & Flink** Introduced `SedonaContext` to unify Sedona entry points.
* [X] **Sedona Spark** Support Spark 3.4.
* [X] **Sedona Spark** Added a number of new ST functions.
* [X] **Zeppelin** Zeppelin helium plugin supports ploting geometries like linestring, polygon.
* [X] **Zeppelin** Zeppelin helium plugin supports plotting geometries like linestring, polygon.

### API change

Expand Down Expand Up @@ -74,7 +74,7 @@ Sedona 1.4.1 is compiled against, Spark 3.3 / Spark 3.4 / Flink 1.12, Java 8.
</li>
<li>[<a href='https://issues.apache.org/jira/browse/SEDONA-239'>SEDONA-239</a>] - Implement ST_NumPoints
</li>
<li>[<a href='https://issues.apache.org/jira/browse/SEDONA-264'>SEDONA-264</a>] - zeppelin helium plugin supports ploting geometry like linestring, polygon
<li>[<a href='https://issues.apache.org/jira/browse/SEDONA-264'>SEDONA-264</a>] - zeppelin helium plugin supports plotting geometry like linestring, polygon
</li>
<li>[<a href='https://issues.apache.org/jira/browse/SEDONA-280'>SEDONA-280</a>] - Add ST_GeometricMedian
</li>
Expand Down Expand Up @@ -335,7 +335,7 @@ GEOGCS["WGS 84",
* [SEDONA-143](https://issues.apache.org/jira/browse/SEDONA-143) - Add missing unit tests for the Flink predicates
* [SEDONA-144](https://issues.apache.org/jira/browse/SEDONA-144) - Add ST_AsGeoJSON to the Flink API
* [SEDONA-145](https://issues.apache.org/jira/browse/SEDONA-145) - Fix ST_AsEWKT to reserve the Z coordinate
* [SEDONA-146](https://issues.apache.org/jira/browse/SEDONA-146) - Add missing output funtions to the Flink API
* [SEDONA-146](https://issues.apache.org/jira/browse/SEDONA-146) - Add missing output functions to the Flink API
* [SEDONA-147](https://issues.apache.org/jira/browse/SEDONA-147) - Add SRID functions to the Flink API
* [SEDONA-148](https://issues.apache.org/jira/browse/SEDONA-148) - Add boolean functions to the Flink API
* [SEDONA-149](https://issues.apache.org/jira/browse/SEDONA-149) - Add Python 3.10 support
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/rdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Assume you now have an SpatialRDD (typed or generic). You can use the following

Besides the rectangle (Envelope) type range query window, Sedona range query window can be Point/Polygon/LineString.

The code to create a point, linestring (4 vertexes) and polygon (4 vertexes) is as follows:
The code to create a point, linestring (4 vertices) and polygon (4 vertices) is as follows:

=== "Scala"

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ A map rendered by accessing the map object created by SedonaKepler includes a co

#### Saving and setting config

A map object's current config can be accessed by accessing its 'config' attribute like `map.config`. This config can be saved for future use or use across notebooks if the exact same map is to be rendered everytime.
A map object's current config can be accessed by accessing its 'config' attribute like `map.config`. This config can be saved for future use or use across notebooks if the exact same map is to be rendered every time.

!!!Note
The map config references each applied customization with the name given to the dataframe and hence will work only on maps with the same name of dataframe supplied.
Expand Down
2 changes: 1 addition & 1 deletion flink-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<plugins>
<plugin>
<!-- Skip running resolved-pom-maven-plugin since shade will
generate dependency reduced pom which substitudes property
generate dependency reduced pom which substitutes property
values. resolved-pom-maven-plugin will break pom
installation when working with maven-shade-plugin. -->
<groupId>io.paradoxical</groupId>
Expand Down
6 changes: 3 additions & 3 deletions python/sedona/sql/st_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def ST_MakeLine(geom1: ColumnOrName, geom2: Optional[ColumnOrName] = None) -> Co
:type geometry: ColumnOrName
:param geom2: Geometry column to convert. If geoms is empty, then geom1 is an array of geometries.
:type geometry: Optional[ColumnOrName], optional
:return: LineString geometry column created from the input geomtries.
:return: LineString geometry column created from the input geometries.
:rtype: Column
"""
args = (geom1,) if geom2 is None else (geom1, geom2)
Expand Down Expand Up @@ -1387,7 +1387,7 @@ def ST_Affine(geometry: ColumnOrName, a: Union[ColumnOrName, float], b: Union[Co
g: Optional[Union[ColumnOrName, float]] = None, h: Optional[Union[ColumnOrName, float]] = None,
i: Optional[Union[ColumnOrName, float]] = None, zOff: Optional[Union[ColumnOrName, float]] = None) -> Column:
"""
Apply a 3D/2D affine tranformation to the given geometry
Apply a 3D/2D affine transformation to the given geometry
x = a * x + b * y + c * z + xOff | x = a * x + b * y + xOff
y = d * x + e * y + f * z + yOff | y = d * x + e * y + yOff
z = g * x + h * y + i * z + zOff
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def ST_CoordDim(geometry: ColumnOrName) -> Column:
:param geometry: Geometry column to return for.
:type geometry: ColumnOrName
:return: Number of dimensinos in a coordinate column as an integer column.
:return: Number of dimensions in a coordinate column as an integer column.
:rtype: Column
"""
return _call_st_function("ST_CoordDim", geometry)
Expand Down
2 changes: 1 addition & 1 deletion spark-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<plugins>
<plugin>
<!-- Skip running resolved-pom-maven-plugin since shade will
generate dependency reduced pom which substitudes property
generate dependency reduced pom which substitutes property
values. resolved-pom-maven-plugin will break pom
installation when working with maven-shade-plugin. -->
<groupId>io.paradoxical</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
* Point: 8 bytes for X coordinate, followed by 8 bytes for Y coordinate.
* LineString is serialized as MultiLineString.
* MultiLineString: 16 bytes for envelope, 4 bytes for the number of line strings,
* 4 bytes for total number of vertexes, 16 * num-vertexes for
* XY coordinates of all the vertexes.
* 4 bytes for total number of vertices, 16 * num-vertices for
* XY coordinates of all the vertices.
* Polygons is serialized as MultiPolygon.
* MultiPolygon: 16 bytes for envelope, 4 bytes for the total number of exterior and
* interior rings of all polygons, 4 bytes for total number of vertexes,
* 16 * num-vertexes for XY coordinates of all the vertexes. The vertexes
* interior rings of all polygons, 4 bytes for total number of vertices,
* 16 * num-vertices for XY coordinates of all the vertices. The vertices
* are written one polygon at a time, exterior ring first, followed by
* interior rings.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private int findRegion(QuadRectangle r, boolean split)
this.split();
}

// can be null if not splitted
// can be null if not split
if (regions != null) {
for (int i = 0; i < regions.length; i++) {
if (regions[i].getZone().contains(r)) {
Expand All @@ -102,7 +102,7 @@ private int findRegion(QuadRectangle r, boolean split)
private int findRegion(int x, int y)
{
int region = REGION_SELF;
// can be null if not splitted
// can be null if not split
if (regions != null) {
for (int i = 0; i < regions.length; i++) {
if (regions[i].getZone().contains(x, y)) {
Expand Down

0 comments on commit 6e8a77d

Please sign in to comment.