Skip to content

Commit 397f84c

Browse files
authored
Merge pull request #41 from mcflugen/mcflugen/add-python-312
Add python 3.12 to tests; remove lint
2 parents a2e4c04 + 137390d commit 397f84c

20 files changed

+315
-312
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: ["3.8", "3.9", "3.10", "3.11"]
16+
python-version: ["3.10", "3.11", "3.12"]
1717

1818
steps:
1919
- uses: actions/checkout@v2
@@ -31,7 +31,3 @@ jobs:
3131
- name: Test
3232
run: |
3333
nox -s test
34-
35-
# - name: Test Notebooks
36-
# run: |
37-
# nox -s test-notebooks

.pre-commit-config.yaml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.1.0
3+
rev: 24.2.0
44
hooks:
55
- id: black
66
name: black
@@ -23,16 +23,16 @@ repos:
2323
additional_dependencies: [".[jupyter]"]
2424

2525
- repo: https://github.com/nbQA-dev/nbQA
26-
rev: 1.6.3
26+
rev: 1.7.1
2727
hooks:
2828
- id: nbqa-pyupgrade
29-
args: ["--py38-plus"]
29+
args: ["--py310-plus"]
3030
- id: nbqa-isort
3131
- id: nbqa-flake8
3232
args: ["--extend-ignore=E402"]
3333

3434
- repo: https://github.com/pycqa/flake8
35-
rev: 6.0.0
35+
rev: 7.0.0
3636
hooks:
3737
- id: flake8
3838
additional_dependencies:
@@ -46,26 +46,26 @@ repos:
4646
)
4747
4848
- repo: https://github.com/kynan/nbstripout
49-
rev: 0.6.1
49+
rev: 0.7.1
5050
hooks:
5151
- id: nbstripout
5252
description: Strip output from jupyter notebooks
5353
args: [--drop-empty-cells]
5454

5555
- repo: https://github.com/asottile/pyupgrade
56-
rev: v3.3.1
56+
rev: v3.15.1
5757
hooks:
5858
- id: pyupgrade
59-
args: [--py36-plus]
59+
args: [--py310-plus]
6060

61-
- repo: https://github.com/PyCQA/isort
62-
rev: 5.12.0
61+
- repo: https://github.com/pycqa/isort
62+
rev: 5.13.2
6363
hooks:
6464
- id: isort
65-
files: \.py$
65+
args: ["--force-single-line-imports"]
6666

6767
- repo: https://github.com/pre-commit/pre-commit-hooks
68-
rev: v4.4.0
68+
rev: v4.5.0
6969
hooks:
7070
- id: check-builtin-literals
7171
- id: check-added-large-files
@@ -83,21 +83,3 @@ repos:
8383
.*requirements(-\w+)?.(in|txt)|
8484
MANIFEST.in
8585
)
86-
87-
- repo: https://github.com/regebro/pyroma
88-
rev: "4.1"
89-
hooks:
90-
- id: pyroma
91-
args: ["-d", "--min=10", "."]
92-
additional_dependencies:
93-
- numpy
94-
- cython
95-
96-
- repo: https://github.com/mgedmin/check-manifest
97-
rev: "0.49"
98-
hooks:
99-
- id: check-manifest
100-
args: ["--ignore=.nox,build", "--no-build-isolation"]
101-
additional_dependencies:
102-
- numpy
103-
- cython

MANIFEST.in

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
[![DOI](https://zenodo.org/badge/310435424.svg)](https://zenodo.org/doi/10.5281/zenodo.10003561)
1+
![[DOI][doi-link]][doi-badge]
2+
3+
4+
[barrier3d-github]:https://github.com/UNC-CECL/Barrier3D
5+
[brie-github]: https://github.com/UNC-CECL/brie
6+
[cascade-figure]: https://user-images.githubusercontent.com/57640439/226623608-d0c58437-d44f-4dca-8f43-0b92623fcda6.png
7+
[chom-github]: https://github.com/UNC-CECL/CHOM
8+
[doi-badge]: https://zenodo.org/badge/310435424.svg
9+
[doi-link]: https://zenodo.org/doi/10.5281/zenodo.10003561
10+
[nox-docs]: https://nox.thea.codes/
11+
[preprint-doi]: https://doi.org/10.31223/X5P947
12+
[zip-download]: https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip
13+
214

315
🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️
416
# cascade
@@ -15,10 +27,10 @@ are incorporated in *cascade* in two separate modules. The first module simulate
1527
pavement damage during overwashing events, including rebuilding roadways at sufficiently low elevations to allow for
1628
burial by overwash, constructing large dunes, and relocating the road into the barrier interior. The second module
1729
incorporates management strategies for maintaining a coastal community, including beach nourishment, dune construction,
18-
and overwash removal. For a full description of model dynamics, please see "The Future of Developed
19-
Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by Anarde et al., (2024, [Earth ArXiv preprint](https://doi.org/10.31223/X5P947)).
30+
and overwash removal. For a full description of model dynamics, please see *"The Future of Developed
31+
Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by Anarde et al., (2024, [Earth ArXiv preprint][preprint-doi])*.
2032

21-
![ModelTimeLoop-01](https://user-images.githubusercontent.com/57640439/226623608-d0c58437-d44f-4dca-8f43-0b92623fcda6.png)
33+
![ModelTimeLoop-01][cascade-figure]
2234

2335
In development: *cascade* represents decisions about coastal land-use (e.g., housing markets) and community-level
2436
mitigation measures using an empirically-grounded agent-based real estate model – the Coastal Home Ownership Model (*chom*).
@@ -42,19 +54,23 @@ on local wave and sediment characteristics as well as the offshore wave climate
4254
Lorenzo-Trueba & Ashton, 2014; Ortiz & Ashton, 2016). For ease of model coupling, *brie* and *chom* were rewritten in Python
4355
and all models (*barrier3d*, *brie*, *chom*) were appended with a basic-model interface with the help of the
4456
Community Surface Dynamics Modeling System. The repositories for the models coupled within *cascade* are noted here:
45-
- *barrier3d*: [GitHub Python Repository - Version 2.0 (BMI)](https://github.com/UNC-CECL/Barrier3D)
46-
- *brie*: [GitHub Python Repository - Version 1.0 (BMI)](https://github.com/UNC-CECL/brie)
47-
- *chom*: [GitHub Python Repository - Version 0.0.1.dev0 (BMI)](https://github.com/UNC-CECL/CHOM)
57+
- *barrier3d*: [GitHub Python Repository - Version 2.0 (BMI)][barrier3d-github]
58+
- *brie*: [GitHub Python Repository - Version 1.0 (BMI)][brie-github]
59+
- *chom*: [GitHub Python Repository - Version 0.0.1.dev0 (BMI)][chom-github]
4860

4961
## Installation
5062

5163
To install the latest release of *cascade* using *pip*, simply run the following in your terminal of choice:
5264

53-
pip install coastal-cascade
65+
```bash
66+
pip install coastal-cascade
67+
```
5468

5569
You can also use `conda`:
5670

57-
conda install coastal-cascade
71+
```bash
72+
conda install coastal-cascade
73+
```
5874

5975
### From Source
6076

@@ -64,51 +80,61 @@ need to get *cascade*'s source code, and then install *cascade* from that code.
6480

6581
To get the source code you can either clone the repository with *git*:
6682

67-
git clone git@github.com/UNC-CECL/cascade
83+
```bash
84+
git clone git@github.com:UNC-CECL/cascade
85+
```
6886

69-
or download a [zip file](https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip):
87+
or download a [zip file][zip-download]:
7088

71-
curl -OL https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip
89+
```bash
90+
curl -OL https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip
91+
```
7292

7393
Once you have a copy of the source code, you can install it into your current
7494
environment,
7595

76-
pip install -e .
96+
```bash
97+
pip install -e .
98+
```
7799

78-
We use [nox] to automate routine maintenance tasks like running the tests,
79-
removing lint, etc. Install [nox] with *pip*::
100+
We use [nox-docs] to automate routine maintenance tasks like running the tests,
101+
removing lint, etc. Install [nox-docs] with *pip*::
80102

81-
pip install nox
103+
```bash
104+
pip install nox
105+
```
82106

83-
When you're done making changes, you can now run [nox] to check that the tests
107+
When you're done making changes, you can now run [nox-docs] to check that the tests
84108
pass and that there isn't any lint:
85109

86-
nox -s test # run the unit tests
87-
nox -s test-notebooks # test that the notebooks run successfully
88-
nox -s lint # find and, where possible, remove lint (black, flake8, etc.)
110+
```bash
111+
nox -s test # run the unit tests
112+
nox -s test-notebooks # test that the notebooks run successfully
113+
nox -s lint # find and, where possible, remove lint (black, flake8, etc.)
114+
```
89115

90116
To run all of the above in a single command:
91117

92-
nox
93-
94-
[nox]: https://nox.thea.codes/
118+
```bash
119+
nox
120+
```
95121

96122
## Example simulations
97-
This ReadMe corresponds to the version of *cascade* used for the simulations detailed in
98-
*"The Future of Developed Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by
99-
Anarde et al., (2024, [Earth ArXiv preprint](https://doi.org/10.31223/X5P947))* -- namely, v1.0.0. For a more complete
123+
This ReadMe corresponds to the version of *cascade* used for the simulations detailed in
124+
*"The Future of Developed Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by
125+
Anarde et al., (2024, [Earth ArXiv preprint][preprint-doi])* -- namely, v1.0.0. For a more complete
100126
set of example model runs and description of module functionality, we direct the use to the examples
101127
provided in `notebooks`.
102128

103129
Example (default) data inputs for cascade are provided in the `data` directory:
104-
```
130+
```python
105131
from cascade.cascade import Cascade
106132

107133
datadir = "data/"
108134
```
109135
To initialize an instance of *cascade* with no human dynamics, 3 barrier segments (each 500-m long), and
110136
default *barrier3d* and *brie* parameters:
111-
```
137+
```python
112138
cascade = Cascade(
113139
datadir,
114140
name="no_human_dynamics_3_barrier_segments",
@@ -120,7 +146,7 @@ cascade = Cascade(
120146
)
121147
```
122148
To initialize an instance of *cascade* with roadway barrier management on 1 barrier segment:
123-
```
149+
```python
124150
cascade = Cascade(
125151
datadir,
126152
name="roadway_mgmt_1_barrier_segments",
@@ -132,7 +158,7 @@ cascade = Cascade(
132158
)
133159
```
134160
To initialize *cascade* with community barrier management on 1 barrier segment:
135-
```
161+
```python
136162
cascade = Cascade(
137163
datadir,
138164
name="community_mgmt_1_barrier_segments",
@@ -144,7 +170,7 @@ cascade = Cascade(
144170
)
145171
```
146172
Once initialized, a *cascade* time loop can be completed as follows:
147-
```
173+
```python
148174
for time_step in range(cascade.time_step_count - 1):
149175
cascade.update()
150176
if cascade.b3d_break:

cascade/beach_dune_manager.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
initial beach slope defined in Barrier3D to develop the storm series. This beach
4040
width is then modified dynamically via nourishment and shoreface dynamics.
4141
"""
42+
4243
import copy
4344
import math
4445

4546
import numpy as np
4647

47-
from .roadway_manager import rebuild_dunes, set_growth_parameters
48+
from .roadway_manager import rebuild_dunes
49+
from .roadway_manager import set_growth_parameters
4850

4951
dm3_to_m3 = 1000 # convert from cubic decameters to cubic meters
5052

@@ -292,9 +294,9 @@ def filter_overwash(
292294
else:
293295
# spread overwash removed from roadway equally over the adjacent dune cells
294296
total_overwash_removal_dune_volume = sum(overwash_removal_dune) # array of dam
295-
total_overwash_removal_dune_volume[
296-
total_overwash_removal_dune_volume < 0
297-
] = 0 # don't let it erode a dune
297+
total_overwash_removal_dune_volume[total_overwash_removal_dune_volume < 0] = (
298+
0 # don't let it erode a dune
299+
)
298300
number_dune_cells = np.size(post_storm_yxz_dune_grid, 1)
299301
overwash_volume_to_dune = np.transpose(
300302
[total_overwash_removal_dune_volume / number_dune_cells] * number_dune_cells
@@ -304,9 +306,9 @@ def filter_overwash(
304306

305307
# don't allow dunes to exceed a maximum height (limits 10-m dunes after big
306308
# storms...yikes!); assume the rest of the sand disappears
307-
new_dune_domain[
308-
new_dune_domain > artificial_maximum_dune_height
309-
] = artificial_maximum_dune_height
309+
new_dune_domain[new_dune_domain > artificial_maximum_dune_height] = (
310+
artificial_maximum_dune_height
311+
)
310312

311313
# dam^3
312314
total_overwash_removal = (
@@ -499,9 +501,9 @@ def abandonment_cleanup_tasks(
499501

500502
# turn dune migration back on
501503
barrier3d.dune_migration_on = True
502-
self._dune_migration_on[
503-
self._time_index - 1
504-
] = barrier3d.dune_migration_on # keep track!
504+
self._dune_migration_on[self._time_index - 1] = (
505+
barrier3d.dune_migration_on
506+
) # keep track!
505507

506508
# set the shoreline change aggregate to the dam (cell) fraction
507509
barrier3d.SCRagg[self._time_index - 1] = (barrier3d.x_s % 1) * -1

cascade/brie_coupler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
In future versions, the coupled model will incorporate tidal inlet dynamics
2828
within BRIE (i.e., the inlet model will be turned on).
2929
"""
30+
3031
import math
3132
import pathlib
3233

3334
import numpy as np
3435
from barrier3d import Barrier3d
3536
from brie import Brie
36-
from yaml import dump, full_load
37+
from yaml import dump
38+
from yaml import full_load
3739

3840

3941
def set_yaml(var_name, new_vals, file_name):

0 commit comments

Comments
 (0)