From 525a9afc13394d0277fc9113bf8dafb9b4651c26 Mon Sep 17 00:00:00 2001 From: Tristan Salles Date: Thu, 20 Jun 2024 22:41:21 +1000 Subject: [PATCH] add flake8 --- .flake8 | 5 +++++ .vscode/settings.json | 5 +++++ docs/api_ref/flow_ref.rst | 10 ++-------- docs/api_ref/in_ref.rst | 2 -- docs/api_ref/sea_ref.rst | 12 ------------ docs/api_ref/sed_ref.rst | 2 -- docs/conf.py | 2 ++ docs/index.rst | 2 +- gospl/tools/cgflex.py | 5 +++-- gospl/tools/inputparser.py | 6 ++++-- 10 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 .flake8 create mode 100644 .vscode/settings.json diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..b61e46d4 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +ignore = E203, E266, E501, W503, F403, F401 +max-line-length = 89 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..611a7585 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "mesonbuild.configureOnOpen": true, + "C_Cpp.default.compileCommands": "/Users/galois/codes/gospl/builddir/compile_commands.json", + "C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild" +} \ No newline at end of file diff --git a/docs/api_ref/flow_ref.rst b/docs/api_ref/flow_ref.rst index 43e7b4a5..e9485ae9 100644 --- a/docs/api_ref/flow_ref.rst +++ b/docs/api_ref/flow_ref.rst @@ -19,17 +19,14 @@ Class FAMesh ~FAMesh.flowAccumulation ~FAMesh.matrixFlow - ~FAMesh.riverIncision .. rubric:: Private Methods .. autosummary:: ~FAMesh._buildFlowDirection - ~FAMesh._distanceCoasts ~FAMesh._distributeDownstream - ~FAMesh._getErosionRate - ~FAMesh._globalCoastsTree + ~FAMesh._getEroDepRatex ~FAMesh._matrix_build ~FAMesh._matrix_build_diag ~FAMesh._solve_KSP @@ -39,17 +36,14 @@ Public functions .. automethod:: flow.flowplex.FAMesh.flowAccumulation .. automethod:: flow.flowplex.FAMesh.matrixFlow -.. automethod:: flow.flowplex.FAMesh.riverIncision Private functions --------------------- .. automethod:: flow.flowplex.FAMesh._buildFlowDirection -.. automethod:: flow.flowplex.FAMesh._distanceCoasts .. automethod:: flow.flowplex.FAMesh._distributeDownstream -.. automethod:: flow.flowplex.FAMesh._getErosionRate -.. automethod:: flow.flowplex.FAMesh._globalCoastsTree +.. automethod:: flow.flowplex.FAMesh._getEroDepRate .. automethod:: flow.flowplex.FAMesh._matrix_build .. automethod:: flow.flowplex.FAMesh._matrix_build_diag .. automethod:: flow.flowplex.FAMesh._solve_KSP diff --git a/docs/api_ref/in_ref.rst b/docs/api_ref/in_ref.rst index 49c4c1f8..dd58c6d0 100644 --- a/docs/api_ref/in_ref.rst +++ b/docs/api_ref/in_ref.rst @@ -20,7 +20,6 @@ Class ReadYaml ~ReadYaml._addTime ~ReadYaml._defineRain ~ReadYaml._defineTectonic - ~ReadYaml._extraCompaction ~ReadYaml._extraDomain ~ReadYaml._readCompaction ~ReadYaml._readDomain @@ -40,7 +39,6 @@ Private functions .. automethod:: tools.inputparser.ReadYaml._addTime .. automethod:: tools.inputparser.ReadYaml._defineRain .. automethod:: tools.inputparser.ReadYaml._defineTectonic -.. automethod:: tools.inputparser.ReadYaml._extraCompaction .. automethod:: tools.inputparser.ReadYaml._extraDomain .. automethod:: tools.inputparser.ReadYaml._readCompaction .. automethod:: tools.inputparser.ReadYaml._readDomain diff --git a/docs/api_ref/sea_ref.rst b/docs/api_ref/sea_ref.rst index 70cb976a..97815cbb 100644 --- a/docs/api_ref/sea_ref.rst +++ b/docs/api_ref/sea_ref.rst @@ -23,14 +23,8 @@ Class SEAMesh .. autosummary:: - ~SEAMesh._diffuseOcean ~SEAMesh._distanceCoasts - ~SEAMesh._distOcean - ~SEAMesh._evalFunction - ~SEAMesh._evalJacobian - ~SEAMesh._getSeaVol ~SEAMesh._globalCoastsTree - ~SEAMesh._matOcean Public functions --------------------- @@ -41,11 +35,5 @@ Public functions Private functions --------------------- -.. automethod:: sed.seaplex.SEAMesh._diffuseOcean .. automethod:: sed.seaplex.SEAMesh._distanceCoasts -.. automethod:: sed.seaplex.SEAMesh._distOcean -.. automethod:: sed.seaplex.SEAMesh._evalFunction -.. automethod:: sed.seaplex.SEAMesh._evalJacobian -.. automethod:: sed.seaplex.SEAMesh._getSeaVol .. automethod:: sed.seaplex.SEAMesh._globalCoastsTree -.. automethod:: sed.seaplex.SEAMesh._matOcean diff --git a/docs/api_ref/sed_ref.rst b/docs/api_ref/sed_ref.rst index 009ae5f6..88bc22f5 100644 --- a/docs/api_ref/sed_ref.rst +++ b/docs/api_ref/sed_ref.rst @@ -26,7 +26,6 @@ Class SEDMesh .. autosummary:: ~SEDMesh._distributeSediment - ~SEDMesh._getSedVol ~SEDMesh._hillSlope ~SEDMesh._moveDownstream ~SEDMesh._updateSinks @@ -43,7 +42,6 @@ Private functions --------------------- .. automethod:: sed.sedplex.SEDMesh._distributeSediment -.. automethod:: sed.sedplex.SEDMesh._getSedVol .. automethod:: sed.sedplex.SEDMesh._hillSlope .. automethod:: sed.sedplex.SEDMesh._moveDownstream .. automethod:: sed.sedplex.SEDMesh._updateSinks diff --git a/docs/conf.py b/docs/conf.py index 32c47e50..b796ef31 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -308,6 +308,8 @@ def __getattr__(cls, name): "scipy.interpolate", "vtk", "vtk.util", + "gflex", + "xarray", ] for m in MOCK_MODULES: diff --git a/docs/index.rst b/docs/index.rst index 74e71ddc..b821ae23 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,7 +17,7 @@ goSPL documentation `Source Repository `__ | `Issues & Ideas `__ -**goSLP** (short for ``Global Scalable Paleo Landscape Evolution`` and pronounced: **/ˈɡospel/**, **[ˈɡo̞s̠pe̞l]**) is an open source, GPL-licensed library providing a scalable parallelised Python-based numerical model to simulate landscapes and basins reconstruction at global scale. goSPL is developed by the `EarthCodeLab Group `_ at the University of Sydney. +**goSPL** (short for ``Global Scalable Paleo Landscape Evolution``) is an open source, GPL-licensed library providing a scalable parallelised Python-based numerical model to simulate landscapes and basins reconstruction at global scale. goSPL is developed by the `EarthCodeLab Group `_ at the University of Sydney. Statement of need diff --git a/gospl/tools/cgflex.py b/gospl/tools/cgflex.py index 0459c7f6..db88f7db 100644 --- a/gospl/tools/cgflex.py +++ b/gospl/tools/cgflex.py @@ -7,13 +7,14 @@ import petsc4py import numpy as np -# import rioxarray import xarray as xr from mpi4py import MPI from pathlib import Path -from gflex.f2d import F2D from time import process_time +if "READTHEDOCS" not in os.environ: + from gflex.f2d import F2D + petsc4py.init(sys.argv) MPIrank = petsc4py.PETSc.COMM_WORLD.Get_rank() MPIsize = petsc4py.PETSc.COMM_WORLD.Get_size() diff --git a/gospl/tools/inputparser.py b/gospl/tools/inputparser.py index fd166142..275b8896 100644 --- a/gospl/tools/inputparser.py +++ b/gospl/tools/inputparser.py @@ -3,10 +3,12 @@ import petsc4py import numpy as np import pandas as pd -from ruamel.yaml import YAML from operator import itemgetter -from scipy.interpolate import interp1d + +if "READTHEDOCS" not in os.environ: + from ruamel.yaml import YAML + from scipy.interpolate import interp1d petsc4py.init(sys.argv) MPIrank = petsc4py.PETSc.COMM_WORLD.Get_rank()