cleder / pygeoif

Basic implementation of the __geo_interface__ 🌐️
https://pygeoif.readthedocs.io
67 stars 27 forks source link

test: initial commit adding hypothesis property testing library #186

Closed bpshaver closed 8 months ago

bpshaver commented 1 year ago

Adding the Hypothesis cache dir to .gitignore Grammar fixes in geometry.py Hypothesis dep in pyproject.toml without version peg Initial strategies in conftest.py. This is the only file name I could use that didn't cause an issue with the name-tests-test pre-commit hook. 'strategies.py' would be better because strictly speaking these aren't fixtures. An example test for encode/decode invariance.

watermelon-copilot-for-code-review[bot] commented 1 year ago

WatermelonAI Summary

AI Summary deactivated by bpshaver

GitHub PRs

what-the-diff[bot] commented 1 year ago

PR Summary

codecov[bot] commented 1 year ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (ff2e39c) 100.00% compared to head (84ed536) 99.87%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 179-add-hypothesis-tests #186 +/- ## ============================================================ - Coverage 100.00% 99.87% -0.13% ============================================================ Files 21 22 +1 Lines 2412 2437 +25 ============================================================ + Hits 2412 2434 +22 - Misses 0 3 +3 ``` | [Files](https://app.codecov.io/gh/cleder/pygeoif/pull/186?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Ledermann) | Coverage Ξ” | | |---|---|---| | [pygeoif/geometry.py](https://app.codecov.io/gh/cleder/pygeoif/pull/186?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Ledermann#diff-cHlnZW9pZi9nZW9tZXRyeS5weQ==) | `100.00% <ΓΈ> (ΓΈ)` | | | [tests/test\_point.py](https://app.codecov.io/gh/cleder/pygeoif/pull/186?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Ledermann#diff-dGVzdHMvdGVzdF9wb2ludC5weQ==) | `100.00% <100.00%> (ΓΈ)` | | | [tests/conftest.py](https://app.codecov.io/gh/cleder/pygeoif/pull/186?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Ledermann#diff-dGVzdHMvY29uZnRlc3QucHk=) | `84.21% <84.21%> (ΓΈ)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cleder commented 1 year ago

I would prefer another file layout and not putting the strategies in conftests and keeping the hypothesis tests separate from the classic unit tests:

The SRS could be defined as a dataclass like

@dataclass(frozen=True)
class Srs:
    name: str
    min_xyz : Tuple[float, float, Optional[float]]
    max_xyz : Tuple[float, float, Optional[float]]     

an instance of an srs can optionally be passed into the points, points_2d, points_3d strategies, if none is provided there would be no max_value, min_valueset for the st.floats

def points_3d(draw, srs: Optional[Srs]):
       ...

and

def points_2d(draw, srs: Optional[Srs] = None):
     easting = (None, None)
     northing = (None, None)
     elevation = (None, None)
     if srs:
         easting = (srs.min_xyz[0], srs.max_xyz[0]
         ...
epsg4326 = Srs(name="EPSG:4326", min_xyz =(-90, 0, None), max_xyz=(90, 180, None)

Hope that helps :+1: nice work

watermelon-copilot-for-code-review[bot] commented 1 year ago

WatermelonAI Summary

AI Summary deactivated by bpshaver

GitHub PRs

cleder commented 1 year ago

You can add an 'exclude' to the name-tests-test pre-commit hook in .pre-commit-config.yaml

      - id: name-tests-test
        exclude: ^tests/hypothesis/strategies.py$
cleder commented 1 year ago

Are you still working on this?

bpshaver commented 1 year ago

Hi, sorry. Will try and get to this tomorrow. But if you want to press on ahead I won't be offended if you remove me from this issue.

cleder commented 1 year ago

No, no worries, we all got a (private) life apart from coding, but I thought I'd better ask, as abandoning an issue is not uncommon. I did not want to put pressure on you, just wanted clarification if it is still of interest

cleder commented 11 months ago

@CodiumAI-Agent /describe

CodiumAI-Agent commented 11 months ago

Title

Integrate Hypothesis Testing Library and Improve Grammar in Comments


Type

Tests, Enhancement


Description

This PR integrates the Hypothesis property-based testing library into the project and adds new test strategies in the 'conftest.py' file. It also improves the grammar in the comments of the 'geometry.py' file. Additionally, a new test case using Hypothesis has been added in 'test_point.py'. The Hypothesis library has been added as a dependency in 'pyproject.toml'.


PR changes walkthrough

Relevant files                                                                                                                                 
Documentation
1 files
geometry.py                                                                                                 
    pygeoif/geometry.py

    Grammar in comments has been improved, specifically changing
    'less' to 'fewer' in three places.
+3/-3
Tests
2 files
conftest.py                                                                                                 
    tests/conftest.py

    New data-generating strategies for property-based testing
    have been added. These strategies generate data for
    latitudes, longitudes, elevations, 2D points, 3D points, and
    generic points.
+52/-0
test_point.py                                                                                             
    tests/test_point.py

    A new test case using Hypothesis has been added to test the
    representation and evaluation of points.
+9/-0
Dependencies
1 files
pyproject.toml                                                                                           
    pyproject.toml

    The Hypothesis library has been added as a dependency.
+1/-0

User description

Adding the Hypothesis cache dir to .gitignore Grammar fixes in geometry.py Hypothesis dep in pyproject.toml without version peg Initial strategies in conftest.py. This is the only file name I could use that didn't cause an issue with the name-tests-test pre-commit hook. 'strategies.py' would be better because strictly speaking these aren't fixtures. An example test for encode/decode invariance.

cleder commented 11 months ago

@CodiumAI-Agent /review

CodiumAI-Agent commented 11 months ago

PR Analysis

How to use

Instructions > Tag me in a comment '@CodiumAI-Agent' and add one of the following commands: > **/review**: Request a review of your Pull Request. > **/describe**: Update the PR title and description based on the contents of the PR. > **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > **/ask \**: Ask a question about the PR. > **/update_changelog**: Update the changelog based on the PR's contents. > **/add_docs**: Generate docstring for new components introduced in the PR. > **/generate_labels**: Generate labels for the PR based on the PR's contents. > see the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To edit any configuration parameter from the [configuration.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml), add --config_path=new_value. >For example: /review --pr_reviewer.extra_instructions="focus on the file: ..." >To list the possible configuration parameters, add a **/config** comment.
cleder commented 11 months ago

@CodiumAI-Agent /improve

cleder commented 8 months ago

you may be interested in #219 or #220 ;-)