Skip to content

Commit 79dd510

Browse files
authored
Merge pull request #340 from kaklise/1.0
Minor update to the snap function and cleanup
2 parents 5c3d94c + 2c3dd2e commit 79dd510

File tree

7 files changed

+35
-27
lines changed

7 files changed

+35
-27
lines changed

.github/workflows/build_tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ jobs:
9090
if: matrix.os == 'windows-latest'
9191
run: | # the following skips windows rst doctests that rely on geopandas (gis.rst and model_io.rst) because skipif is not working properly
9292
coverage erase
93-
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*" -m pytest --doctest-modules --doctest-glob="*.rst" wntr
94-
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*" --append -m pytest --doctest-glob="*.rst" --ignore-glob="*model_io.rst" --ignore-glob="*gis.rst" documentation
93+
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*","*/sim/network_isolation/network_isolation.py","*/sim/aml/evaluator.py" -m pytest --doctest-modules --doctest-glob="*.rst" wntr
94+
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*","*/sim/network_isolation/network_isolation.py","*/sim/aml/evaluator.py" --append -m pytest --doctest-glob="*.rst" --ignore-glob="*model_io.rst" --ignore-glob="*gis.rst" documentation
9595
env:
9696
COVERAGE_FILE: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
9797
- name: Run Tests
9898
if: matrix.os != 'windows-latest'
9999
run: |
100100
coverage erase
101-
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*" -m pytest --doctest-modules --doctest-glob="*.rst" wntr
102-
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*" --append -m pytest --doctest-glob="*.rst" documentation
101+
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*","*/sim/network_isolation/network_isolation.py","*/sim/aml/evaluator.py" -m pytest --doctest-modules --doctest-glob="*.rst" wntr
102+
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=wntr --omit="*/tests/*","*/sim/network_isolation/network_isolation.py","*/sim/aml/evaluator.py" --append -m pytest --doctest-glob="*.rst" documentation
103103
env:
104104
COVERAGE_FILE: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
105105

.github/workflows/quick_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
python -m pip install -e .
3434
- name: Run tests and coverage (unittests plus doctests)
3535
run: |
36-
coverage run --source=wntr --omit="*/tests/*" -m pytest -m "not time_consuming" --doctest-modules --doctest-glob="*.rst" wntr
36+
coverage run --source=wntr --omit="*/tests/*","*/sim/network_isolation/network_isolation.py","*/sim/aml/evaluator.py" -m pytest -m "not time_consuming" --doctest-modules --doctest-glob="*.rst" wntr
3737
coverage report --fail-under=70
3838
# coverage run --source=wntr --omit="*/tests/*" --append -m pytest --doctest-glob="*.rst" documentation
3939

documentation/whatsnew.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Release notes
22
================
33

4-
.. _whatsnew_060:
4+
.. _whatsnew_100:
55

6-
.. include:: whatsnew/v0.6.0.rst
6+
.. include:: whatsnew/v1.0.0.rst
77

88
.. _whatsnew_050:
99

documentation/whatsnew/v0.6.0.rst renamed to documentation/whatsnew/v1.0.0.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
v0.6.0 (main)
1+
v1.0.0 (March 30, 2023)
22
---------------------------------------------------
3+
WNTR version 1.0.0 has undergone extensive testing
4+
with a wide range of water distribution system models
5+
and analysis options. The software has also successfully been
6+
used by external research groups and in analysis that uses large-scale
7+
water distribution system models. See
8+
`User community <https://wntr.readthedocs.io/en/latest/users.html>`_
9+
for a list of publications and software that uses WNTR.
10+
11+
* Updated copyright and added EPANET license
12+
`#336 <https://github.com/USEPA/WNTR/pull/336>`_.
13+
14+
* Updated the setup process and documentation
15+
`#335 <https://github.com/USEPA/WNTR/pull/335>`_.
16+
317
* Bug fix to allow for np.float and np.int in type checking
418
`#334 <https://github.com/USEPA/WNTR/pull/334>`_.
519

wntr/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
# shapely and geopandas are optional dependencies of WNTR. If shapely
2-
# version is >= 2.0, the environment variable USE_PYGEOS is set to '0' to
3-
# ensure geopandas uses shapely over pygeos. Future versions of
4-
# geopandas will use shapely by default.
5-
try:
6-
import shapely
7-
if int(shapely.__version__.split('.')[0]) >= 2:
8-
import os
9-
os.environ['USE_PYGEOS'] = '0'
10-
except ModuleNotFoundError:
11-
pass
12-
131
from wntr import epanet
142
from wntr import network
153
from wntr import morph
@@ -20,7 +8,7 @@
208
from wntr import gis
219
from wntr import utils
2210

23-
__version__ = '0.6.0dev'
11+
__version__ = '1.0.0'
2412

2513
__copyright__ = """Copyright 2023 National Technology & Engineering
2614
Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525

wntr/gis/geospatial.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def snap(A, B, tolerance):
4949
5050
If B contains Lines or MultiLineString, columns include:
5151
- link: closest Line in B to Point in A
52-
- node: start or end node of Line in B that is closest to the snapped point
52+
- node: start or end node of Line in B that is closest to the snapped point (if B contains columns "start_node_name" and "end_node_name")
5353
- snap_distance: distance between Point A and snapped point
5454
- line_position: normalized distance of snapped point along Line in B from the start node (0.0) and end node (1.0)
5555
- geometry: GeoPandas Point object of the snapped point
@@ -126,9 +126,12 @@ def snap(A, B, tolerance):
126126
snapped_points = gpd.GeoDataFrame(data=closest ,geometry=snapped_points, crs=crs)
127127
# determine whether the snapped point is closer to the start or end node
128128
snapped_points["line_position"] = closest.geometry.project(snapped_points, normalized=True)
129-
snapped_points.loc[snapped_points["line_position"]<0.5, "node"] = closest["start_node_name"]
130-
snapped_points.loc[snapped_points["line_position"]>=0.5, "node"] = closest["end_node_name"]
131-
snapped_points = snapped_points[["link", "node", "snap_distance", "line_position", "geometry"]]
129+
if ("start_node_name" in closest.columns) and ("end_node_name" in closest.columns):
130+
snapped_points.loc[snapped_points["line_position"]<0.5, "node"] = closest["start_node_name"]
131+
snapped_points.loc[snapped_points["line_position"]>=0.5, "node"] = closest["end_node_name"]
132+
snapped_points = snapped_points[["link", "node", "snap_distance", "line_position", "geometry"]]
133+
else:
134+
snapped_points = snapped_points[["link", "snap_distance", "line_position", "geometry"]]
132135
snapped_points.index.name = None
133136

134137
return snapped_points

wntr/tests/test_sim_performance.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import unittest
3+
import pytest
34
from os.path import abspath, dirname, join
45
import threading
56
import time
@@ -245,7 +246,8 @@ def test_Net3_performance_PDA(self):
245246
rel_threshold,
246247
)
247248
)
248-
249+
250+
@pytest.mark.time_consuming
249251
def test_Net6_thread_performance(self):
250252
"""
251253
Test thread-safe performance of simulators
@@ -303,7 +305,8 @@ def run_wntr(wn, name):
303305
t2.join()
304306
thr_time = time.time()-start_time
305307
self.assertGreaterEqual(seq_time - thr_time, -1, 'WNTR threading took 1s longer than sequential')
306-
308+
309+
@pytest.mark.time_consuming
307310
def test_Net6_mod_performance(self):
308311
head_diff_abs_threshold = 1e-3
309312
demand_diff_abs_threshold = 1e-5

0 commit comments

Comments
 (0)