Skip to content

Commit 7e78bb6

Browse files
- changed test scripts to remove fixtures and start parameterizing using pytest-cases plugin
- updated management of `TEST_DATA` variable and moved its descendents to conftest.py - updated location of images dir to docs dir - deprecated modules `agreement_map.py`, `test_integration.py`, and `tests/utils.py` - updated `spatial_alignment.py` to allow for `xr.Datasets` (not currently reflected in tests) - deprecate `check_for_single_band_raster()` - added test module for `load_raster_as_xarray()` - updated docstring for `_is_not_natural_number()` - converting input arg for `_is_not_natural_number(x)` to int to control for overflowerror - converted `matching_spatial_indices()` to use `xr.align(*args,join='exact')` - updated `transform_bounds()` to remove dst_crs arg - renamed target_map to _crs on `transform_bounds()` - made changes to `_check_file()` to avoid reopening S3 client and moved s3 name to module variable - added `_build_map_file_path()` to help build filepaths for test data - moved case with xarray objects up in if/else block within `align_rasters` - general housekeeping
1 parent 74279ea commit 7e78bb6

20 files changed

+794
-572
lines changed

README.MD

Lines changed: 58 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ maps and metrics.
77
NOTE: THIS PACKAGE IS UNDER ACTIVE DEVELOPMENT AND NOT CURRENTLY
88
FUNCTIONING. BREAKING CHANGES ARE OFTEN INTRODUCED.
99

10-
![alt text](./images/ExampleWorkflow.png)
10+
![alt text](../../docs/images/ExampleWorkflow.png)
1111

1212
# Installation
1313

@@ -21,18 +21,18 @@ To use this package:
2121

2222
## Standards
2323

24-
- Python 3.10 or higher
25-
- [Numpy Style Docstrings](https://numpydoc.readthedocs.io/en/v1.1.0/format.html#documenting-modules)
26-
- [Python Type Hints](https://docs.python.org/3/library/typing.html)
27-
- [PEP8](https://pep8.org/) Styling (and
28-
[this](https://peps.python.org/pep-0008/))
24+
- Python 3.10 or higher
25+
- [Numpy Style Docstrings](https://numpydoc.readthedocs.io/en/v1.1.0/format.html#documenting-modules)
26+
- [Python Type Hints](https://docs.python.org/3/library/typing.html)
27+
- [PEP8](https://pep8.org/) Styling (and
28+
[this](https://peps.python.org/pep-0008/))
2929

3030
## Code Dependencies
3131

32-
- [rioxarray](https://corteva.github.io/rioxarray/html/index.html)
33-
- [geopandas](https://geopandas.org/en/stable/)
34-
- [dask](https://www.dask.org)
35-
- [xarray-spatial](https://xarray-spatial.org)
32+
- [rioxarray](https://corteva.github.io/rioxarray/html/index.html)
33+
- [geopandas](https://geopandas.org/en/stable/)
34+
- [dask](https://www.dask.org)
35+
- [xarray-spatial](https://xarray-spatial.org)
3636

3737
# Contributing
3838

@@ -44,8 +44,8 @@ To use this package:
4444
4545
There are two primary ways to help:
4646

47-
- Using the issue tracker, and
48-
- Changing the code-base.
47+
- Using the issue tracker, and
48+
- Changing the code-base.
4949

5050
## Using the issue tracker
5151

@@ -67,7 +67,7 @@ stylistic and architectural guidelines prescribed by the project. In the
6767
absence of such guidelines, mimic the styles and patterns in the
6868
existing code-base.
6969

70-
![alt text](./images/ContributionGraphic.png)
70+
![alt text](../../docs/images/ContributionGraphic.png)
7171

7272
### Guidelines
7373

@@ -87,34 +87,33 @@ If you would like to contribute, please follow the following steps:
8787

8888
## Tooling Dependencies
8989

90-
- Code Checking with [Flake8](https://github.com/PyCQA/flake8)
91-
- Combines PyFlakes, pycodestyle, and others for linting and style
92-
checking.
93-
- For autoformatting:
94-
[flake8-black](https://pypi.org/project/flake8-black/)
95-
- Testing with
96-
[PyTest](https://docs.pytest.org/en/7.1.x/contents.html)
97-
- For timed tests:
98-
[pytest-benchmark](https://pypi.org/project/pytest-benchmark/)
99-
- For code coverage:
100-
[pytest-cov](https://pypi.org/project/pytest-cov/)
101-
- Profiling
102-
- [yappi](https://github.com/sumerc/yappi/)
103-
- For memory profiling: [memray](https://pypi.org/project/memray/)
104-
- Dask memory profiling:
105-
[dask-memusage](https://github.com/itamarst/dask-memusage)
106-
- Dependencies and Packaging
107-
- [pip](https://packaging.python.org/en/latest/key_projects/#pip)
108-
- Docker
109-
- Distribution
110-
- [PyPI](https://pypi.org/)
111-
- DockerHub
112-
- GitHub (source, packaging, and images)
113-
- Docs
114-
- [Sphinx](https://www.sphinx-doc.org/)
115-
- [pandoc](https://pypi.org/project/pandoc/)
116-
- [ReadTheDocs](https://readthedocs.org/)
117-
- [Jupyter](https://pypi.org/project/jupyter/)
90+
- Code Checking with [Flake8](https://github.com/PyCQA/flake8)
91+
- Combines PyFlakes, pycodestyle, and others for linting and style
92+
checking.
93+
- For autoformatting:
94+
[flake8-black](https://pypi.org/project/flake8-black/)
95+
- Testing with [PyTest](https://docs.pytest.org/en/7.1.x/contents.html)
96+
- For timed tests:
97+
[pytest-benchmark](https://pypi.org/project/pytest-benchmark/)
98+
- For code coverage:
99+
[pytest-cov](https://pypi.org/project/pytest-cov/)
100+
- Profiling
101+
- [yappi](https://github.com/sumerc/yappi/)
102+
- For memory profiling: [memray](https://pypi.org/project/memray/)
103+
- Dask memory profiling:
104+
[dask-memusage](https://github.com/itamarst/dask-memusage)
105+
- Dependencies and Packaging
106+
- [pip](https://packaging.python.org/en/latest/key_projects/#pip)
107+
- Docker
108+
- Distribution
109+
- [PyPI](https://pypi.org/)
110+
- DockerHub
111+
- GitHub (source, packaging, and images)
112+
- Docs
113+
- [Sphinx](https://www.sphinx-doc.org/)
114+
- [pandoc](https://pypi.org/project/pandoc/)
115+
- [ReadTheDocs](https://readthedocs.org/)
116+
- [Jupyter](https://pypi.org/project/jupyter/)
118117

119118
## Development Installation
120119

@@ -125,68 +124,62 @@ choice.)
125124

126125
First setup docker instance and in the root directory of the project:
127126

128-
` [sudo] docker build -t gval-image --target development . `
127+
`[sudo] docker build -t gval-image --target development . `
129128

130129
The default user named 'user' with UID 1001 is created. To use the same
131130
user and permissions you currently have on your machine override with
132131
build arguments:
133132

134-
`[sudo] docker build -t gval-image --build-arg UID=$(id -u) --target
135-
development .`
133+
`[sudo] docker build -t gval-image --build-arg UID=$(id -u) --target development .`
136134

137135
Standard run examples from the command line (standard, or overriding
138136
user with root):
139137

140-
- `[sudo] docker run -v $(pwd):/home/user/gval --name gval-python
141-
gval-image`
142-
- `[sudo] docker run -v $(pwd):/home/user/gval --user root --name
143-
gval-python gval-image`
138+
- `[sudo] docker run -v $(pwd):/home/user/gval --name gval-python gval-image`
139+
- `[sudo] docker run -v $(pwd):/home/user/gval --user root --name gval-python gval-image`
144140

145141
If given access keys for retrieving test data you can mount the volume
146142
as such:
147143

148-
`[sudo] docker run -v ~/.aws:/home/user/.aws -v $(pwd):/home/user/gval
149-
--name gval-python gval-image`
144+
`[sudo] docker run -v ~/.aws:/home/user/.aws -v $(pwd):/home/user/gval --name gval-python gval-image`
150145

151146
To keep your container running, try adding `tail -f /dev/null` as your
152147
command ensuring to detach with `-d`:
153148

154-
- `[sudo] docker run -d -v $(pwd):/home/user/gval --name gval-python
155-
gval-image tail -f /dev/null`
149+
- `[sudo] docker run -d -v $(pwd):/home/user/gval --name gval-python gval-image tail -f /dev/null`
156150

157151
You can also set up your IDE to run this docker image directly:
158152

159-
- [PyCharm](https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html#config-docker)
160-
- [Visual Studio
161-
Code](https://code.visualstudio.com/docs/containers/quickstart-python)
153+
- [PyCharm](https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html#config-docker)
154+
- [Visual Studio
155+
Code](https://code.visualstudio.com/docs/containers/quickstart-python)
162156

163157
If the container already exists you can start as follows:
164158

165159
`[sudo] docker start gval-python`
166160

167-
To enter the container interactively: `[sudo] docker exec gval-python
168-
bash`
161+
To enter the container interactively:
162+
`[sudo] docker exec gval-python bash`
169163

170164
## Packaging
171165

172166
To build the gval package and install locally:
173167

174-
- In the root directory install the gVal package:
168+
- In the root directory install the gVal package:
175169

176-
`python -m build && pip install dist/*.whl --force-reinstall`
170+
`python -m build && pip install dist/*.whl --force-reinstall`
177171

178-
- Or on Windows replacing version number with current version number:
172+
- Or on Windows replacing version number with current version number:
179173

180-
`py -m build` then get the name of the wheel in the dist directory,
181-
e.g.:
174+
`py -m build` then get the name of the wheel in the dist directory,
175+
e.g.:
182176

183-
`pip install dist/gval-0.0.1-py3-none-any.whl --force-reinstall`
177+
`pip install dist/gval-0.0.1-py3-none-any.whl --force-reinstall`
184178

185179
The packaging process using docker container would look as follows (on
186180
linux):
187181

188-
`sudo docker exec -v $(pwd):/home/user/ --user root python -m build &&
189-
pip install dist/*.whl --force-reinstall`
182+
`sudo docker exec -v $(pwd):/home/user/ --user root python -m build && pip install dist/*.whl --force-reinstall`
190183

191184
# Citation
192185

config.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
"""
2+
Package-level configuration file.
3+
"""
4+
5+
# __all__ = ['*']
6+
__author__ = "Fernando Aristizabal, Gregory Petrochenkov"
7+
8+
19
import os
210

3-
# Get absolute path of file
4-
abs_path = os.path.dirname(os.path.abspath(__file__))
511

6-
TEST_DATA = os.path.join(abs_path, "data", "data")
7-
# TEST_DATA = os.path.join("s3://gval-test")
8-
# AWS_KEYS = os.path.join(abs_path, "data", "access_keys.csv")
12+
# defines absolute path of project's root directory
13+
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
914

1015

1116
if __name__ == "__main__":
File renamed without changes.
File renamed without changes.

docs/markdown/01_INTRO.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ gVal (pronounced "g-val") is a high-level Python framework to evaluate the geosp
33

44
NOTE: THIS PACKAGE IS UNDER ACTIVE DEVELOPMENT AND NOT CURRENTLY FUNCTIONING. BREAKING CHANGES ARE OFTEN INTRODUCED.
55

6-
![alt text](../../images/ExampleWorkflow.png)
6+
![alt text](../../docs/images/ExampleWorkflow.png)

docs/markdown/05_CONTRIBUTING.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Additionally, the code should follow any stylistic and architectural guidelines
3232
prescribed by the project. In the absence of such guidelines, mimic the styles
3333
and patterns in the existing code-base.
3434

35-
![alt text](../../images/ContributionGraphic.png)
35+
![alt text](../../docs/images/ContributionGraphic.png)
3636

3737
### Guidelines
3838

gval/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from gval.outputs.agreement_map import Agreement_map
21
from gval.homogenize.spatial_alignment import Spatial_alignment
32
from gval.utils.exceptions import RasterMisalignment, RastersNotSingleBand
43
from gval.utils.loading_datasets import load_raster_as_xarray

gval/compare.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,30 @@ def _is_not_natural_number(x: Number) -> int:
2828
"""
2929
Checks value to see if it is a natural number or two non-negative integer [0, 1, 2, 3, 4, ...)
3030
31-
FIXME: Must return boolean or some other numba type. Having trouble returning none.
31+
Parameters
32+
----------
33+
x : Number
34+
Number to test.
35+
36+
Returns
37+
-------
38+
int
39+
Return -2 by default. Issue with numba usage. Please ignore for now.
40+
FIXME: Must return boolean or some other numba type. Having trouble returning none.
41+
42+
Raises
43+
------
44+
ValueError
45+
If x not a natural number.
3246
"""
3347
# checks to make sure it's not a nan value
3448
if np.isnan(x):
3549
return -2 # dummy return
3650
# checks for non-negative and whole number
37-
elif (x < 0) | ((x - int(x)) != 0):
51+
elif (x < 0) | ((x - nb.int64(x)) != 0):
3852
# FIXME: how to print x with message below using numba????
3953
raise ValueError(
40-
"Negative or non-whole number found (non-negative integers) [0, 1, 2, 3, 4, ...)"
54+
"Non natural number found (non-negative integers, excluding Inf) [0, 1, 2, 3, 4, ...)"
4155
)
4256
# must return something according to signature
4357
else:

0 commit comments

Comments
 (0)