diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index ad556da..0000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Black - -on: [push, pull_request] - -jobs: - - lint: - # We want to run on external PRs, but not on our own internal PRs as they'll be run - # by the push to the branch. Without this if check, checks are duplicated since - # internal PRs match both the push and pull_request events. - if: - github.event_name == 'push' || github.event.pull_request.head.repo.full_name != - github.repository - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: psf/black@stable - with: - args: ". --check" diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..ed0d4d3 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,25 @@ +name: Check + +on: + pull_request: + types: [labeled, unlabeled, opened, reopened, synchronize] + +jobs: + check-changelog-entry: + name: changelog entry + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + # `towncrier check` runs `git diff --name-only origin/main...`, which + # needs a non-shallow clone. + fetch-depth: 0 + + - name: Check changelog + if: "!contains(github.event.pull_request.labels.*.name, 'Skip Changelog')" + run: | + if ! pipx run towncrier check --compare-with origin/${{ github.base_ref }}; then + echo "Please see https://landlab.readthedocs.io/en/master/development/contribution/index.html?highlight=towncrier#news-entries for guidance." + false + fi diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index af33a60..e051f46 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,9 +26,9 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - + runs-on: ubuntu-latest - + defaults: run: shell: bash -l {0} @@ -44,11 +44,10 @@ jobs: - name: Show conda installation info run: conda info - + - name: Install dependencies run: | - conda install --file=requirements.txt - pip install -e ".[doc]" + pip install nox - name: Build documentation - run: make -C docs clean html + run: nox -s build-docs diff --git a/.github/workflows/flake8.yml b/.github/workflows/lint.yml similarity index 88% rename from .github/workflows/flake8.yml rename to .github/workflows/lint.yml index 3338036..d9bd825 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,11 @@ -name: Flake8 +name: Lint on: [push, pull_request] jobs: lint: + name: Check for lint # We want to run on external PRs, but not on our own internal PRs as they'll be run # by the push to the branch. Without this if check, checks are duplicated since # internal PRs match both the push and pull_request events. @@ -22,5 +23,5 @@ jobs: - name: Lint run: | - pip install flake8 - flake8 sequence tests + pip install nox + nox -s lint diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index fab152c..1e5fdcf 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -11,9 +11,9 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - + runs-on: ubuntu-latest - + defaults: run: shell: bash -l {0} @@ -29,10 +29,9 @@ jobs: - name: Show conda installation info run: conda info - + - name: Install dependencies - run: | - pip install -e ".[notebook,dev]" + run: pip install nox - - name: Test notebooks - run: pytest --nbmake notebooks/*ipynb + - name: Build documentation + run: nox -s test-notebooks diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 48681cb..7e38419 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -28,7 +28,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: "3.9" - + - name: Install twine run: | pip install --upgrade pip wheel setuptools @@ -36,11 +36,11 @@ jobs: python --version pip --version twine --version - + - name: Create source distribution run: | python setup.py sdist --dist-dir wheelhouse - + - name: Upload source distribution run: | twine upload --skip-existing wheelhouse/*.tar.gz diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0bbd9c..a43d7ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: "3.9" - + - name: Install twine run: | pip install --upgrade pip wheel setuptools @@ -36,11 +36,11 @@ jobs: python --version pip --version twine --version - + - name: Create source distribution run: | python setup.py sdist --dist-dir wheelhouse - + - name: Upload source distribution run: | twine upload --skip-existing wheelhouse/*.tar.gz diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2883de7..4a02b59 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,26 +35,11 @@ jobs: - name: Show conda installation info run: conda info - - name: Build and install package - run: | - conda install rasterio richdem -c conda-forge - pip install . - - - name: Install testing dependencies - run: pip install ".[dev]" - - - name: Test package - run: | - python -c 'import sequence; print(sequence.__version__)' - pytest --cov=sequence --cov-report= --cov-report=xml -vvv - - - name: Test command line - run: | - sequence --version - mkdir example - sequence --cd=example setup --set clock.stop=60000 - sequence --cd=example --silent run - sequence --cd=data/marmara --silent run + - name: Install dependencies + run: pip install nox + + - name: Build documentation + run: nox -s test - name: Coveralls if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3cab59d..08906d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,11 +21,13 @@ repos: require_serial: true types_or: [python, pyi, jupyter] additional_dependencies: [".[jupyter]"] + - repo: https://gitlab.com/pycqa/flake8 rev: 3.9.2 hooks: - id: flake8 # additional_dependencies: [flake8-bugbear] + - repo: https://gitlab.com/iamlikeme/nbhooks rev: 1.0.0 hooks: @@ -35,9 +37,38 @@ repos: entry: nb-ensure-clean files: \.ipynb$ language: python - language_version: python3 + language_version: python3.8 + - repo: https://github.com/asottile/pyupgrade rev: v2.34.0 hooks: - id: pyupgrade args: [--py38-plus] + +- repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + files: \.py$ + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-builtin-literals + - id: check-added-large-files + - id: check-case-conflict + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: trailing-whitespace + +# - repo: https://github.com/PyCQA/pydocstyle +# rev: 6.1.1 +# hooks: +# - id: pydocstyle +# files: sequence/.*\.py$ +# args: +# - --convention=numpy +# - --add-select=D417 diff --git a/CHANGES.rst b/CHANGES.rst index 5ff9312..e9dc17a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -172,7 +172,7 @@ Other Changes and Additions 0.1.2 (2020-03-04) ------------------- +------------------ - Added sediment compaction @@ -206,12 +206,11 @@ Other Changes and Additions 0.1.1 (2018-08-24) ------------------- +------------------ - Added versioneer for version management 0.1.0 (2018-08-24) ------------------- +------------------ - Initial release - diff --git a/LICENSE.rst b/LICENSE.rst index e8d3d39..b3d56f7 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -23,4 +23,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/MANIFEST.in b/MANIFEST.in index 699eed3..e39ac74 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,4 +9,3 @@ recursive-exclude docs * recursive-exclude news * recursive-exclude notebooks * recursive-exclude tests * - diff --git a/README.rst b/README.rst index e54fad8..71d3e6d 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ :target: https://sequence.readthedocs.io/en/develop/?badge=develop :alt: Sequence :align: center - + .. raw:: html

Sequence-stratigraphic modeling with Python

@@ -149,12 +149,12 @@ and then plots the output. The above can also be run through Python, -.. code:: python +.. code:: pycon >>> from sequence import Sequence, SequenceModelGrid >>> grid = SequenceModelGrid(100, spacing=1000.0) >>> grid.at_node["topographic__elevation"] = -0.001 * grid.x_of_node + 20.0 - + >>> sequence = Sequence() >>> sequence.run() >>> sequence.plot() @@ -163,10 +163,12 @@ The ``Sequence`` class provides functionality not available to the command-line program. For example, you are able to run a simulation through time while dynamically changing parameters. - >>> from sequence import Sequence, SequenceModelGrid +.. code:: pycon + + >>> from sequence import Sequence, SequenceModelGrid >>> grid = SequenceModelGrid(100, spacing=1000.0) >>> grid.at_node["topographic__elevation"] = -0.001 * grid.x_of_node + 20.0 - + >>> process = default_process_queue() >>> sequence = Sequence( ... grid, @@ -178,8 +180,8 @@ changing parameters. ... process["flexure"], ... process["shoreline"], ... ] - ... ) - + ... ) + >>> sequence.run(until=300000.0, dt=100.0) >>> sequence.submarine_diffusion.sediment_load *= 2.0 >>> sequence.run(until=600000.0, dt=100.0) @@ -199,7 +201,9 @@ The main *Sequence* input file is a *toml*-formatted (or, optionally, *yaml*) text file that lists parameter values for the various components. Running the following will print a sample *Sequence* parameter file:: - $ sequence generate sequence.toml +.. code:: bash + + sequence generate sequence.toml Following is the generated input file, @@ -283,7 +287,7 @@ The grid section You define the grid on which *Sequence* will run in the `sequence.grid` section. An example gid section looks like, -.. code:: +.. code:: toml [sequence.grid] shape = [3, 500] @@ -309,7 +313,7 @@ The output section You can define when and what *Sequence* will save to a NetCDF file while it is running. Here is an example output section, -.. code:: +.. code:: toml [sequence.output] interval = 10 @@ -363,7 +367,9 @@ Bathymetry File The *Sequence* bathymetry file defines initial sea-floor elevations in a two-column CSV file. A sample bathymetry file can be obtained with:: - $ sequence generate bathymetry.csv +.. code:: bash + + sequence generate bathymetry.csv # X [m], Elevation [m] 0.0,20.0 100000.0,-80.0 @@ -378,7 +384,9 @@ The *Sequence* sea-level file defines sea-level elevations with simulation time. It consists of two (comma separated) columns of time and sea-level elevation, respectively. For a sample sea-level file:: - $ sequence generate sealevel.csv +.. code:: bash + + sequence generate sealevel.csv # Time [y], Sea-Level Elevation [m] 0.0,0.0 200000.0,-10.0 @@ -391,7 +399,9 @@ the profile. It consists of two (comma separated) columns that give position along the profile and subsidence rate, respectively. For a sample subsidence file:: - $ sequence generate subsidence.csv +.. code:: bash + + sequence generate subsidence.csv # X [y], Subsidence Rate [m / y] 0.0,0.0 30000.0,0.0 @@ -422,13 +432,17 @@ Examples To run a simulation using the sample input files described above, you first need to create a set of sample files:: - $ mkdir example - $ cd example && sequence setup +.. code:: bash + + mkdir example + cd example && sequence setup example You can now run the simulation (from within the *example* folder):: - $ sequence run +.. code:: bash + + sequence run Plotting output --------------- @@ -439,9 +453,9 @@ The *Sequence* program provides a command-line utility for generating a quick plot of *Sequence* output from a NetCDF file named *sequence.nc*. As an example, -.. code:: +.. code:: bash - $ sequence plot + sequence plot If you would like to change some aspects of the generated plot, you can add a *sequence.plot* section to your *sequence.toml* file. For example, here @@ -473,4 +487,3 @@ not be obvious, * *n_layers*: the number of layers to plot. .. end-plotting - diff --git a/data/Default.yaml b/data/Default.yaml index 7d9da20..439477d 100644 --- a/data/Default.yaml +++ b/data/Default.yaml @@ -17,6 +17,6 @@ sl_type: 'sinusoid' sl_file_name : 'sample_sea_level_file.txt' sea_level_phase : 0. - sea_level_amplitude : 10. + sea_level_amplitude : 10. sea_level_period : 100000. -... \ No newline at end of file +... diff --git a/data/marmara.yaml b/data/marmara.yaml index 9dabf0d..488751b 100644 --- a/data/marmara.yaml +++ b/data/marmara.yaml @@ -34,4 +34,4 @@ sediments: mud_size: 0.006, sand_density: 2650. mud_density: 2720. - sand_frac: 0.5 \ No newline at end of file + sand_frac: 0.5 diff --git a/data/params.yaml b/data/params.yaml index a3a6b33..f3e3a80 100644 --- a/data/params.yaml +++ b/data/params.yaml @@ -1,32 +1,3 @@ -<<<<<<< HEAD -grid : - shape : [3, 100] - spacing': 100. - origin': 0. - bc': - top': 'closed' - bottom': 'closed' -clock: - start : -20000. - stop : 0. - step : 100. -submarine_diffusion : - wave_base : 60. - shoreface_height : 15. - alpha : .0005 - shelf_slope : .001 - sediment_load : 1. - plain_slope : 0.0008 -sea_level : - amplitude : 10. - wave_length : 1000. - phase : 0. -subsidence: - filepath : 'subsidence.csv' -flexure : - method : 'airy' - rho_mantle : 3300. -======= clock: start: -20000.0 step: 100.0 @@ -57,4 +28,3 @@ subsidence: flexure: method: airy rho_mantle: 3300. ->>>>>>> 0d8ccf5ce3563ac60ddf26e0f9170480df1598f3 diff --git a/data/sample_sea_level_file.txt b/data/sample_sea_level_file.txt index 56a6e0f..08beaf3 100644 --- a/data/sample_sea_level_file.txt +++ b/data/sample_sea_level_file.txt @@ -1,200 +1,200 @@ --20000 200. --19900 -3.3 --19800 -52.4 --19700 -120.4 --19600 -122.2 --19500 -99.1 --19400 -102.6 --19300 -91 --19200 -85.7 --19100 -80.4 --19000 -75.3 --18900 -87.8 --18800 -76.1 --18700 -85.2 --18600 -57.9 --18500 -52.9 --18400 -47.4 --18300 -49 --18200 -55.1 --18100 -50.6 --18000 -39.2 --17900 -42.8 --17800 -72.4 --17700 -4.3 --17600 24 --17500 -1.9 --17400 -76.3 --17300 -96.9 --17200 -107.7 --17100 -97 --17000 -93.9 --16900 -102.2 --16800 -90.3 --16700 -78.5 --16600 -67.8 --16500 -72 --16400 -81.7 --16300 -45.3 --16200 -49 --16100 -18.2 --16000 -34.2 --15900 -17.6 --15800 -13.4 --15700 -7.3 --15600 -23.6 --15500 -74.1 --15400 -68.3 --15300 -59.5 --15200 -28.6 --15100 -60.3 --15000 -66.8 --14900 -85.4 --14800 -79.1 --14700 -79.7 --14600 -86 --14500 -54.1 --14400 -43.4 --14300 -39.3 --14200 -39.5 --14100 -55.8 --14000 -45.8 --13900 -39.7 --13800 -34.8 --13700 -23 --13600 -31.4 --13500 11.1 --13400 -16.8 --13300 -26 --13200 -83.1 --13100 -96.8 --13000 -92 --12900 -90.6 --12800 -104 --12700 -55.4 --12600 -85.2 --12500 -58.4 --12400 -52.7 --12300 -52.1 --12200 -31.9 --12100 -30.6 --12000 -9.5 --11900 12.5 --11800 12.8 --11700 -0.2 --11500 -29.5 --11400 -84.7 --11300 -115.3 --11200 -122.1 --11100 -122.7 --11000 -102.4 --10900 -84.8 --10800 -87.5 --10700 -82.7 --10600 -99.9 --10500 -96.7 --10400 -73.7 --10300 -53.4 --10200 -35 --10100 -34.9 --10000 -39.7 --9900 -23.4 --9800 -60.8 --9700 -68.6 --9600 -78.8 --9500 -61.2 --9400 -54.8 --9300 -78.3 --9200 -75.3 --9100 -84.6 --9000 -73.7 --8900 -66.5 --8800 -73 --8700 -65 --8600 -50.6 --8500 -41.6 --8400 -25.6 --8300 -25.6 --8200 -67.6 --8100 -79.1 --8000 -56.5 --7900 -49 --7800 -52.8 --7700 -39.2 --7600 -50.7 --7500 -72.9 --7400 -117.8 --7300 -124.2 --7200 -114.3 --7100 -122.7 --7000 -111.9 --6900 -106.4 --6800 -101.6 --6700 -93.3 --6600 -80.5 --6500 -91.7 --6400 -80 --6300 -82.8 --6200 -82.4 --6100 -53.8 --6000 -62.2 --5900 -70.5 --5800 -78.9 --5700 -87.2 --5600 -95.1 --5500 -96.4 --5400 -63.7 --5300 -70.4 --5200 -75.5 --5100 -77.6 --5000 -73.6 --4900 -86.1 --4800 -91.5 --4700 -85.4 --4600 -62.3 --4500 -53 --4400 -45.1 --4300 -21.8 --4200 -44.2 --4100 -48.5 --4000 -98 --3900 -82.5 --3800 -77.2 --3700 -58.6 --3600 -41.3 --3500 -55.7 --3400 -52.6 --3300 -51.1 --3200 -48.4 --3100 -27.6 --3000 -24.3 --2900 -36.2 --2800 -33 --2700 -19.3 --2600 -61.6 --2500 -83.6 --2400 -109.3 --2300 -106.9 --2200 -93.7 --2100 -90.1 --2000 -84.3 --1900 -64.2 --1800 -60.3 --1700 -74.6 --1600 -89.1 --1500 -66.8 --1400 -51.5 --1300 -31.2 --1200 -22.2 --1100 -19.8 --1000 -9.8 --900 2 --800 -40.6 --700 -41.1 --600 -57.3 --500 -38.6 --400 -27.9 --300 -42.6 --200 -46.6 --100 -29.3 -1 -48.1 \ No newline at end of file +-20000 200. +-19900 -3.3 +-19800 -52.4 +-19700 -120.4 +-19600 -122.2 +-19500 -99.1 +-19400 -102.6 +-19300 -91 +-19200 -85.7 +-19100 -80.4 +-19000 -75.3 +-18900 -87.8 +-18800 -76.1 +-18700 -85.2 +-18600 -57.9 +-18500 -52.9 +-18400 -47.4 +-18300 -49 +-18200 -55.1 +-18100 -50.6 +-18000 -39.2 +-17900 -42.8 +-17800 -72.4 +-17700 -4.3 +-17600 24 +-17500 -1.9 +-17400 -76.3 +-17300 -96.9 +-17200 -107.7 +-17100 -97 +-17000 -93.9 +-16900 -102.2 +-16800 -90.3 +-16700 -78.5 +-16600 -67.8 +-16500 -72 +-16400 -81.7 +-16300 -45.3 +-16200 -49 +-16100 -18.2 +-16000 -34.2 +-15900 -17.6 +-15800 -13.4 +-15700 -7.3 +-15600 -23.6 +-15500 -74.1 +-15400 -68.3 +-15300 -59.5 +-15200 -28.6 +-15100 -60.3 +-15000 -66.8 +-14900 -85.4 +-14800 -79.1 +-14700 -79.7 +-14600 -86 +-14500 -54.1 +-14400 -43.4 +-14300 -39.3 +-14200 -39.5 +-14100 -55.8 +-14000 -45.8 +-13900 -39.7 +-13800 -34.8 +-13700 -23 +-13600 -31.4 +-13500 11.1 +-13400 -16.8 +-13300 -26 +-13200 -83.1 +-13100 -96.8 +-13000 -92 +-12900 -90.6 +-12800 -104 +-12700 -55.4 +-12600 -85.2 +-12500 -58.4 +-12400 -52.7 +-12300 -52.1 +-12200 -31.9 +-12100 -30.6 +-12000 -9.5 +-11900 12.5 +-11800 12.8 +-11700 -0.2 +-11500 -29.5 +-11400 -84.7 +-11300 -115.3 +-11200 -122.1 +-11100 -122.7 +-11000 -102.4 +-10900 -84.8 +-10800 -87.5 +-10700 -82.7 +-10600 -99.9 +-10500 -96.7 +-10400 -73.7 +-10300 -53.4 +-10200 -35 +-10100 -34.9 +-10000 -39.7 +-9900 -23.4 +-9800 -60.8 +-9700 -68.6 +-9600 -78.8 +-9500 -61.2 +-9400 -54.8 +-9300 -78.3 +-9200 -75.3 +-9100 -84.6 +-9000 -73.7 +-8900 -66.5 +-8800 -73 +-8700 -65 +-8600 -50.6 +-8500 -41.6 +-8400 -25.6 +-8300 -25.6 +-8200 -67.6 +-8100 -79.1 +-8000 -56.5 +-7900 -49 +-7800 -52.8 +-7700 -39.2 +-7600 -50.7 +-7500 -72.9 +-7400 -117.8 +-7300 -124.2 +-7200 -114.3 +-7100 -122.7 +-7000 -111.9 +-6900 -106.4 +-6800 -101.6 +-6700 -93.3 +-6600 -80.5 +-6500 -91.7 +-6400 -80 +-6300 -82.8 +-6200 -82.4 +-6100 -53.8 +-6000 -62.2 +-5900 -70.5 +-5800 -78.9 +-5700 -87.2 +-5600 -95.1 +-5500 -96.4 +-5400 -63.7 +-5300 -70.4 +-5200 -75.5 +-5100 -77.6 +-5000 -73.6 +-4900 -86.1 +-4800 -91.5 +-4700 -85.4 +-4600 -62.3 +-4500 -53 +-4400 -45.1 +-4300 -21.8 +-4200 -44.2 +-4100 -48.5 +-4000 -98 +-3900 -82.5 +-3800 -77.2 +-3700 -58.6 +-3600 -41.3 +-3500 -55.7 +-3400 -52.6 +-3300 -51.1 +-3200 -48.4 +-3100 -27.6 +-3000 -24.3 +-2900 -36.2 +-2800 -33 +-2700 -19.3 +-2600 -61.6 +-2500 -83.6 +-2400 -109.3 +-2300 -106.9 +-2200 -93.7 +-2100 -90.1 +-2000 -84.3 +-1900 -64.2 +-1800 -60.3 +-1700 -74.6 +-1600 -89.1 +-1500 -66.8 +-1400 -51.5 +-1300 -31.2 +-1200 -22.2 +-1100 -19.8 +-1000 -9.8 +-900 2 +-800 -40.6 +-700 -41.1 +-600 -57.3 +-500 -38.6 +-400 -27.9 +-300 -42.6 +-200 -46.6 +-100 -29.3 +1 -48.1 diff --git a/data/subsidence_marmara.csv b/data/subsidence_marmara.csv index 416165b..36d4c7b 100644 --- a/data/subsidence_marmara.csv +++ b/data/subsidence_marmara.csv @@ -2,4 +2,4 @@ 30000., 0 35000., -.00015 50000., -.00005 -100000., -.00005 \ No newline at end of file +100000., -.00005 diff --git a/data/test.yaml b/data/test.yaml index 7668396..f5323db 100644 --- a/data/test.yaml +++ b/data/test.yaml @@ -7,4 +7,3 @@ output_interval: 1000.0 output_filename: "seq_test" ... - diff --git a/data/test_input_file.txt b/data/test_input_file.txt index b037277..bb6fa98 100644 --- a/data/test_input_file.txt +++ b/data/test_input_file.txt @@ -8,4 +8,4 @@ profile ={sl_cp: 0.0008, hgt: 15., alpha: 0.0005, wavebase: 60., sl_sh: 0.001 # Initial run parameters run = {load: 0.3} #sealevel_file: -diff = {k_sh: 100.} \ No newline at end of file +diff = {k_sh: 100.} diff --git a/docs/_static/powered-by-logo-header.png b/docs/_static/powered-by-logo-header.png deleted file mode 100644 index 46c82d0..0000000 Binary files a/docs/_static/powered-by-logo-header.png and /dev/null differ diff --git a/docs/_static/sequence-logo-dark.png b/docs/_static/sequence-logo-dark.png deleted file mode 100644 index 565e7fa..0000000 Binary files a/docs/_static/sequence-logo-dark.png and /dev/null differ diff --git a/docs/_static/sequence-logo-dark.svg b/docs/_static/sequence-logo-dark.svg new file mode 100644 index 0000000..07ea79d --- /dev/null +++ b/docs/_static/sequence-logo-dark.svg @@ -0,0 +1,268 @@ + + + + + + + + 2022-07-02T11:23:11.404995 + image/svg+xml + + + Matplotlib v3.5.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/_static/sequence-logo-light.png b/docs/_static/sequence-logo-light.png deleted file mode 100644 index dcf242e..0000000 Binary files a/docs/_static/sequence-logo-light.png and /dev/null differ diff --git a/docs/_static/sequence-logo-light.svg b/docs/_static/sequence-logo-light.svg new file mode 100644 index 0000000..21828aa --- /dev/null +++ b/docs/_static/sequence-logo-light.svg @@ -0,0 +1,268 @@ + + + + + + + + 2022-07-02T11:20:43.511536 + image/svg+xml + + + Matplotlib v3.5.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/_templates/sidebaroutro.html b/docs/_templates/sidebaroutro.html deleted file mode 100644 index bbf0fec..0000000 --- a/docs/_templates/sidebaroutro.html +++ /dev/null @@ -1,3 +0,0 @@ - - Powered by CSDMS - diff --git a/docs/api/index.rst b/docs/api/index.rst index f6342ba..ca7d562 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -4,5 +4,4 @@ Developer Documentation .. toctree:: :maxdepth: 2 - modules - + sequence diff --git a/docs/conf.py b/docs/conf.py index 8e54afd..211c29f 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,7 +21,6 @@ import sequence - if os.environ.get("READTHEDOCS", ""): # RTD doesn't use the repo's Makefile to build docs. import subprocess @@ -122,8 +121,6 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] -# html_logo = "_static/powered-by-logo-header.png" -# html_logo = "_static/sequence-logo-text-lowercase.png" # -- Options for HTMLHelp output --------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index 0d48792..5a637c8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,11 +1,11 @@ -.. image:: _static/sequence-logo-light.png +.. image:: _static/sequence-logo-light.svg :align: center :scale: 15% :alt: Sequence :target: https://sequence.readthedocs.org/ :class: only-light -.. image:: _static/sequence-logo-dark.png +.. image:: _static/sequence-logo-dark.svg :align: center :scale: 15% :alt: Sequence diff --git a/docs/input-files.rst b/docs/input-files.rst index 553a668..1f4cc25 100644 --- a/docs/input-files.rst +++ b/docs/input-files.rst @@ -3,4 +3,4 @@ Input Files .. include:: ../README.rst :start-after: .. start-input-files - :end-before: .. end-input-files \ No newline at end of file + :end-before: .. end-input-files diff --git a/docs/installation.rst b/docs/installation.rst index ec2c859..6fc941d 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -3,4 +3,4 @@ Installation .. include:: ../README.rst :start-after: .. start-installation - :end-before: .. end-installation \ No newline at end of file + :end-before: .. end-installation diff --git a/docs/notebooks.rst b/docs/notebooks.rst index 2046a8a..cabf464 100644 --- a/docs/notebooks.rst +++ b/docs/notebooks.rst @@ -1 +1 @@ -.. include:: ../notebooks/README.rst \ No newline at end of file +.. include:: ../notebooks/README.rst diff --git a/docs/plotting.rst b/docs/plotting.rst index 0ae53ea..1d4b43b 100644 --- a/docs/plotting.rst +++ b/docs/plotting.rst @@ -3,4 +3,4 @@ Plotting Output .. include:: ../README.rst :start-after: .. start-plotting - :end-before: .. end-plotting \ No newline at end of file + :end-before: .. end-plotting diff --git a/docs/requirements.rst b/docs/requirements.rst index d9a87db..3a9606d 100644 --- a/docs/requirements.rst +++ b/docs/requirements.rst @@ -3,4 +3,4 @@ Requirements .. include:: ../README.rst :start-after: .. start-requirements - :end-before: .. end-requirements \ No newline at end of file + :end-before: .. end-requirements diff --git a/docs/usage.rst b/docs/usage.rst index c8b1e27..63ce382 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -3,4 +3,4 @@ Usage .. include:: ../README.rst :start-after: .. start-usage - :end-before: .. end-usage \ No newline at end of file + :end-before: .. end-usage diff --git a/news/58.docs b/news/58.docs index 4138cbc..b7f6a24 100644 --- a/news/58.docs +++ b/news/58.docs @@ -1,3 +1,2 @@ Updated the *sequence* documentation to include a page for `example notebooks `_. - diff --git a/news/59.docs b/news/59.docs index 1b10913..890d020 100644 --- a/news/59.docs +++ b/news/59.docs @@ -1,3 +1,2 @@ Reorganized and cleaned up the documentation and switched to the `furo `_ theme. - diff --git a/news/60.misc b/news/60.misc index ec66582..a3dc9f4 100644 --- a/news/60.misc +++ b/news/60.misc @@ -1,3 +1,2 @@ Set up `nox `_ to automate testing and routine package maintenance. - diff --git a/notebooks/README.rst b/notebooks/README.rst index 6468b1b..6c09a7a 100644 --- a/notebooks/README.rst +++ b/notebooks/README.rst @@ -1,7 +1,7 @@ Example Notebooks ================= -This page is provides an index to the *Sequence* Jupyter Notebooks. +This page is provides an index to the *Sequence* Jupyter Notebooks. **Useful links** @@ -19,5 +19,3 @@ through Python. * `View notebook `_ * `Launch notebook on CSDMS JupyterHub `_ - - diff --git a/noxfile.py b/noxfile.py index 11f0624..a99f19a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,26 +5,30 @@ import nox +PROJECT = "sequence" +ROOT = pathlib.Path(__file__).parent + @nox.session -def tests(session: nox.Session) -> None: +def test(session: nox.Session) -> None: """Run the tests.""" - session.install("pytest") session.install(".[dev]") - session.run("pytest", "--cov=sequence", "-vvv") - session.run("coverage", "report", "--ignore-errors", "--show-missing") - # "--fail-under=100", + args = session.posargs or ["-n", "auto", "--cov", PROJECT, "-vvv"] + if "CI" in os.environ: + args.append("--cov-report=xml:$(pwd)/coverage.xml") + session.run("pytest", *args) -@nox.session -def notebooks(session: nox.Session) -> None: + +@nox.session(name="test-notebooks") +def test_notebooks(session: nox.Session) -> None: """Run the notebooks.""" session.install(".[dev,notebook]") session.run("pytest", "--nbmake", "notebooks/") -@nox.session -def cli(session: nox.Session) -> None: +@nox.session(name="test-cli") +def test_cli(session: nox.Session) -> None: """Test the command line interface.""" session.install(".") session.run("sequence", "--version") @@ -57,8 +61,6 @@ def lint(session: nox.Session) -> None: session.install("pre-commit") session.run("pre-commit", "run", "--all-files") - towncrier(session) - @nox.session def towncrier(session: nox.Session) -> None: @@ -67,16 +69,61 @@ def towncrier(session: nox.Session) -> None: session.run("towncrier", "check", "--compare-with", "origin/develop") -@nox.session -def docs(session: nox.Session) -> None: +@nox.session(name="build-docs", reuse_venv=True) +def build_docs(session: nox.Session) -> None: """Build the docs.""" + with session.chdir(ROOT): + session.install(".[doc]") + + clean_docs(session) + + with session.chdir(ROOT): + session.run( + "sphinx-apidoc", + "-e", + "-force", + "--no-toc", + "--module-first", + "--templatedir", + "docs/_templates", + "-o", + "docs/api", + "sequence", + ) + session.run( + "sphinx-build", + "-b", + "html", + "-W", + "docs", + "build/html", + ) + + +@nox.session(name="live-docs", reuse_venv=True) +def live_docs(session: nox.Session) -> None: + session.install("sphinx-autobuild") session.install(".[doc]") - - session.chdir("docs") - if os.path.exists("_build"): - shutil.rmtree("_build") - session.run("sphinx-apidoc", "--force", "-o", "api", "../sequence") - session.run("sphinx-build", "-b", "html", "-W", ".", "_build/html") + session.run( + "sphinx-apidoc", + "-e", + "-force", + "--no-toc", + "--module-first", + "--templatedir", + "docs/_templates", + "-o", + "docs/api", + "sequence", + ) + session.run( + "sphinx-autobuild", + "-b", + "dirhtml", + "docs", + "build/html", + "--open-browser", + ) @nox.session @@ -129,9 +176,6 @@ def publish_pypi(session): @nox.session(python=False) def clean(session): """Remove all .venv's, build files and caches in the directory.""" - PROJECT = "sequence" - ROOT = pathlib.Path(__file__).parent - shutil.rmtree("build", ignore_errors=True) shutil.rmtree("wheelhouse", ignore_errors=True) shutil.rmtree(f"{PROJECT}.egg-info", ignore_errors=True) @@ -142,3 +186,15 @@ def clean(session): p.rmdir() else: p.unlink() + + +@nox.session(python=False, name="clean-docs") +def clean_docs(session: nox.Session) -> None: + """Clean up the docs folder.""" + with session.chdir(ROOT / "build"): + if os.path.exists("html"): + shutil.rmtree("html") + + with session.chdir(ROOT / "docs"): + for p in pathlib.Path("api").rglob("sequence*.rst"): + p.unlink() diff --git a/pyproject.toml b/pyproject.toml index 8309ea9..0219c16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ dev = [ "pytest-cov", "pytest-datadir", "pytest-runner", + "pytest-xdist", "towncrier", ] doc = [ @@ -73,7 +74,6 @@ notebook = [ [project.scripts] sequence = "sequence.cli:sequence" -testy = "sequence.testy:app" [tool.setuptools] packages = ["sequence"] diff --git a/sequence/__init__.py b/sequence/__init__.py index f613a4c..3e933a2 100644 --- a/sequence/__init__.py +++ b/sequence/__init__.py @@ -1,15 +1,11 @@ from ._version import __version__ from .grid import SequenceModelGrid -from .output_writer import OutputWriter from .sequence import Sequence -from .submarine import SubmarineDiffuser +from .sequence_model import SequenceModel __all__ = [ "__version__", - "OutputWriter", "Sequence", - "SubmarineDiffuser", - "SeaLevelTimeSeries", + "SequenceModel", "SequenceModelGrid", - "SinusoidalSeaLevel", ] diff --git a/sequence/cli.py b/sequence/cli.py index 110bc12..3ed430f 100644 --- a/sequence/cli.py +++ b/sequence/cli.py @@ -6,7 +6,6 @@ # import click import numpy as np - import rich_click as click import tomlkit as toml import yaml @@ -17,7 +16,6 @@ from .raster_model import load_model_params, load_params_from_strings from .sequence_model import SequenceModel - click.rich_click.ERRORS_SUGGESTION = ( "Try running the '--help' flag for more information." ) diff --git a/sequence/fluvial.py b/sequence/fluvial.py index 33f7e06..b700333 100644 --- a/sequence/fluvial.py +++ b/sequence/fluvial.py @@ -58,12 +58,22 @@ def __init__( ---------- grid: ModelGrid A landlab grid. - sand_frac: str + sand_frac: str, optional Fraction of sand on the delta. - sea_level: float, optional - The current sea level (m). + start : float, optional + The initial time of the component. wave_base: float, optional Wave base (m). + sediment_load : float, optional + Sediment load. + sand_density : float, optional + The grain density of sand [kg / m^3] + plain_slope : float, optional + The gradient of the flood plain. + hemipelagic : float, optional + Hemipelagic sedimentation. + sea_level: float, optional + The current sea level (m). """ diff --git a/sequence/input_reader.py b/sequence/input_reader.py index 0452e71..96a4b79 100644 --- a/sequence/input_reader.py +++ b/sequence/input_reader.py @@ -237,7 +237,7 @@ def _add_flattened_item(keys, value, base=None): level = expanded for k in parent: if k not in level: - level[k] = dict() + level[k] = {} level = level[k] if isinstance(value, tuple): value = list(value) @@ -247,7 +247,7 @@ def _add_flattened_item(keys, value, base=None): def _expand_dict(flat_dict): - expanded = dict() + expanded = {} for key, value in flat_dict.items(): _add_flattened_item(key, value, base=expanded) return expanded diff --git a/sequence/netcdf.py b/sequence/netcdf.py index 7292ea6..c854240 100644 --- a/sequence/netcdf.py +++ b/sequence/netcdf.py @@ -180,6 +180,8 @@ def to_netcdf( Indices of elements to write. names: array_link or str, optional Names of fields to write to the netCDF file. + with_layers : bool, optional + Indicate if the NetCDF file should contain the grid's layers. """ if with_layers and format != "NETCDF4": raise ValueError("Grid layers are only available with the NETCDF4 format.") diff --git a/sequence/processes.py b/sequence/processes.py index bb8b8c3..6267168 100644 --- a/sequence/processes.py +++ b/sequence/processes.py @@ -7,7 +7,6 @@ from .submarine import SubmarineDiffuser from .subsidence import SubsidenceTimeSeries - __all__ = [ "Compact", "Fluvial", diff --git a/sequence/raster_model.py b/sequence/raster_model.py index fcd0901..ca3dd0a 100644 --- a/sequence/raster_model.py +++ b/sequence/raster_model.py @@ -116,7 +116,7 @@ def main(cls): def load_params_from_strings(values): - params = dict() + params = {} for param in values: dotted_name, value = param.split("=") params.update(dots_to_dict(dotted_name, yaml.safe_load(value))) @@ -129,7 +129,7 @@ def dots_to_dict(name, value): level = base names = name.split(".") for k in names[:-1]: - level[k] = dict() + level[k] = {} level = level[k] level[names[-1]] = value return base diff --git a/sequence/sea_level.py b/sequence/sea_level.py index 2dafb5f..56363cf 100644 --- a/sequence/sea_level.py +++ b/sequence/sea_level.py @@ -35,6 +35,8 @@ def __init__(self, grid, filepath, kind="linear", start=0.0, **kwds): Kind of interpolation as a string (one of 'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'). Default is 'linear'. + start : float, optional + Set the initial time for the component. """ super().__init__(grid, **kwds) @@ -95,6 +97,18 @@ def __init__( ---------- grid: ModelGrid A landlab grid. + wave_length : float, optional + The wave length of the sea-level curve in [y]. + amplitude : float, optional + The amplitude of the sea-level curve. + phase : float, optional + The phase shift of the sea-level curve [y]. + mean : float, optional + Mean sea-level (disregarding any trend with time). + start : float, optional + The time of the component [y]. + linear : float, optional + Linear trend of the sea-level curve with time [m / y]. """ wave_length /= 2.0 * np.pi super(SeaLevelTimeSeries, self).__init__(grid, **kwds) diff --git a/sequence/sequence.py b/sequence/sequence.py index 3ebbba6..c445dfc 100644 --- a/sequence/sequence.py +++ b/sequence/sequence.py @@ -1,8 +1,7 @@ import numpy as np -from tqdm import trange - from landlab import Component from landlab.layers import EventLayers +from tqdm import trange from .plot import plot_grid @@ -102,6 +101,8 @@ def run(self, until=None, dt=None, progress_bar=True): until : float, optional The time (in years) to run the model to. If not provided, run for a single time step. + dt : float, optional + Run using a time step other than what the component was initialized with. progress_bar : bool, optional If ``True`` display a progress bar while the model is running. """ diff --git a/sequence/sequence_model.py b/sequence/sequence_model.py index 2adfa00..322d720 100644 --- a/sequence/sequence_model.py +++ b/sequence/sequence_model.py @@ -8,8 +8,6 @@ from .bathymetry import BathymetryReader from .fluvial import Fluvial - -# from .raster_model import RasterModel from .input_reader import load_config from .output_writer import OutputWriter from .sea_level import SeaLevelTimeSeries, SinusoidalSeaLevel diff --git a/sequence/shoreline.py b/sequence/shoreline.py index 4ffca10..a28be7e 100644 --- a/sequence/shoreline.py +++ b/sequence/shoreline.py @@ -139,6 +139,11 @@ def find_shelf_edge(x, dz, x_of_shore=0.0, alpha=0.0005): x-positions of the profile. dz : ndarray of float Deposit thickness. + x_of_shore : float, optional + The x-position of the shoreline. + alpha : float, optional + Constant used in interpolating the precise location of the + shoreline. Returns ------- diff --git a/setup.cfg b/setup.cfg index 76d20ab..21c73cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ universal = 1 [flake8] exclude = docs -ignore = +ignore = E203 E501 W503 diff --git a/tests/test_input/sequence.toml b/tests/test_input/sequence.toml index da37b44..9b60bdf 100644 --- a/tests/test_input/sequence.toml +++ b/tests/test_input/sequence.toml @@ -50,4 +50,3 @@ wave_base = 60.0 [sequence.subsidence] filepath = "subsidence.csv" - diff --git a/tests/test_input/sequence.yaml b/tests/test_input/sequence.yaml index d101253..98e10b4 100644 --- a/tests/test_input/sequence.yaml +++ b/tests/test_input/sequence.yaml @@ -58,4 +58,3 @@ submarine_diffusion: wave_base: 60.0 subsidence: filepath: subsidence.csv - diff --git a/tests/test_output_writer.py b/tests/test_output_writer.py index d477a39..dac021b 100644 --- a/tests/test_output_writer.py +++ b/tests/test_output_writer.py @@ -3,7 +3,7 @@ from landlab import RasterModelGrid from pytest import approx, raises -from sequence import OutputWriter +from sequence.output_writer import OutputWriter def test_no_fields(tmpdir):