Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
300 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/asottile/reorder_python_imports | ||
rev: v2.3.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[flake8] | ||
ignore = E203 | ||
max-line-length = 119 | ||
|
||
[pep8] | ||
ignore = E265,E501,W504 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from zmapio import ZMAPGrid | ||
|
||
z_text = """! File created by DMBTools2.GridFileFormats.ZmapPlusFile | ||
! | ||
@GRID FILE, GRID, 4 | ||
20, -9999.0000000, , 7, 1 | ||
6, 4, 0, 200, 0, 300 | ||
0.0, 0.0, 0.0 | ||
@ | ||
-9999.0000000 -9999.0000000 3.0000000 32.0000000 | ||
88.0000000 13.0000000 | ||
-9999.0000000 20.0000000 8.0000000 42.0000000 | ||
75.0000000 5.0000000 | ||
5.0000000 100.0000000 35.0000000 50.0000000 | ||
27.0000000 1.0000000 | ||
2.0000000 36.0000000 10.0000000 6.0000000 | ||
9.0000000 -9999.0000000 | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def zmap_object(tmpdir): | ||
x = tmpdir.join("test.dat") | ||
x.write(z_text) | ||
z_obj = ZMAPGrid(x.strpath) | ||
yield z_obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import json | ||
|
||
|
||
def test_export_to_csv(zmap_object, tmpdir): | ||
x = tmpdir.join("output.csv") | ||
zmap_object.to_csv(x.strpath) | ||
lines = x.readlines() | ||
assert len(lines) == 24 | ||
assert lines[0] == "0.0,300.0,nan\n" | ||
|
||
|
||
def test_export_to_geojson(zmap_object, tmpdir): | ||
x = tmpdir.join("output.json") | ||
zmap_object.to_geojson(x.strpath) | ||
d = json.load(x) | ||
assert sorted(list(d.keys())) == ["coordinates", "type"] | ||
assert d.get("type") == "MultiPoint" | ||
assert len(d.get("coordinates")) == 24 | ||
assert [0.0, 60.0, 88.0] in d.get("coordinates") | ||
|
||
|
||
def test_export_to_wkt(zmap_object, tmpdir): | ||
x = tmpdir.join("output.wkt") | ||
zmap_object.to_wkt(x.strpath) | ||
with open(x.strpath) as f: | ||
line = f.readline() | ||
assert line.startswith("MULTIPOINT ((0.0000000 300.0000000 nan),") | ||
|
||
|
||
def test_export_to_wkt_with_precision(zmap_object, tmpdir): | ||
x = tmpdir.join("output.wkt") | ||
zmap_object.to_wkt(x.strpath, precision=2) | ||
with open(x.strpath) as f: | ||
line = f.readline() | ||
assert line.startswith("MULTIPOINT ((0.00 300.00 nan),") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
def test_read_comments_section(zmap_object): | ||
assert len(zmap_object.comments) == 2 | ||
assert zmap_object.comments[0].startswith( | ||
" File created by DMBTools2.GridFileFormats" | ||
) | ||
|
||
|
||
def test_columns_rows_count(zmap_object): | ||
assert zmap_object.no_cols == 4 | ||
assert zmap_object.no_rows == 6 | ||
|
||
|
||
def test_max_min_values(zmap_object): | ||
assert zmap_object.max_x == 200.0 | ||
assert zmap_object.min_x == 0.0 | ||
assert zmap_object.max_y == 300.0 | ||
assert zmap_object.min_y == 0.0 | ||
|
||
|
||
def test_decimal_places(zmap_object): | ||
assert zmap_object.decimal_places == 7 | ||
|
||
|
||
def test_nodes_per_line(zmap_object): | ||
assert zmap_object.nodes_per_line == 4 | ||
|
||
|
||
def test_null_values(zmap_object): | ||
assert zmap_object.null_value == -9999 | ||
assert zmap_object.null_value_2 == "" | ||
|
||
|
||
def test_start_column(zmap_object): | ||
assert zmap_object.start_column == 1 | ||
|
||
|
||
def test_x_values(zmap_object): | ||
assert zmap_object.x_values.shape == (6, 4) | ||
|
||
|
||
def test_y_values(zmap_object): | ||
assert zmap_object.y_values.shape == (6, 4) | ||
|
||
|
||
def test_z_values(zmap_object): | ||
assert zmap_object.z_values.shape == (4, 6) | ||
|
||
|
||
def test_z_type(zmap_object): | ||
assert zmap_object.z_type == "GRID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from zmapio import ZMAPGrid | ||
|
||
z_text = """!this is | ||
!a test | ||
@test, GRID, 4 | ||
20, -9999.0, , 7, 1 | ||
6, 4, 0.0, 200.0, 0.0, 300.0 | ||
0.0, 0.0, 0.0 | ||
@ | ||
-9999.0000000 -9999.0000000 3.0000000 32.0000000 | ||
88.0000000 13.0000000 | ||
-9999.0000000 20.0000000 8.0000000 42.0000000 | ||
75.0000000 5.0000000 | ||
5.0000000 100.0000000 35.0000000 50.0000000 | ||
27.0000000 1.0000000 | ||
2.0000000 36.0000000 10.0000000 6.0000000 | ||
9.0000000 -9999.0000000 | ||
""" | ||
|
||
|
||
def test_write_zmap_file(zmap_object, tmpdir): | ||
x = tmpdir.join("output.dat") | ||
z = ZMAPGrid( | ||
z_values=zmap_object.z_values, min_x=0.0, max_x=200.0, min_y=0.0, max_y=300.0 | ||
) | ||
z.comments = ["this is", "a test"] | ||
z.nodes_per_line = 4 | ||
z.field_width = 20 | ||
z.decimal_places = 7 | ||
z.name = "test" | ||
z.null_value = -9999.0 | ||
z.write(x.strpath) | ||
|
||
with open(x.strpath) as f: | ||
data = f.read() | ||
assert data == z_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from .zmap import ZMAPGrid | ||
from .__version__ import __version__ | ||
from .__version__ import __version__ # noqa: F401 | ||
from .zmap import ZMAPGrid # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.4.0' | ||
__version__ = "0.5.0" |
Oops, something went wrong.