Skip to content

Commit 0a688aa

Browse files
authored
Merge pull request #118 from Serapieum-of-alex/refactor-rename
Clean up
2 parents 92f333d + bc1aec0 commit 0a688aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+6169
-5054
lines changed

.coveralls.yml

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

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore = E203, E266, E501, W503, C901, E722, E731, W605, E712, F841, D202
2+
ignore = E203, E266, E501, W503, C901, E722, E731, W605, E712, F841, D202, D203
33
max-line-length = 88
44
max-complexity = 18
55
select = B,C,E,F,W,T4

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555
- name: Generate coverage report
5656
run: |
5757
python -m pytest -vvv --cov=Hapi --cov-report=xml
58-
58+
5959
- name: Upload coverage reports to Codecov with GitHub Action
6060
uses: codecov/codecov-action@v3

.pre-commit-config.yaml

Lines changed: 90 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,114 @@
1+
fail_fast: true
12
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
4-
hooks:
5-
- id: end-of-file-fixer
6-
name: "[py - check] validate yaml"
7-
- id: trailing-whitespace
8-
name: "[file - format] trim trailing whitespace"
9-
args: [ --markdown-linebreak-ext=md ]
10-
- id: check-added-large-files
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.1.0
5+
hooks:
6+
- id: end-of-file-fixer
7+
name: "[py - check] validate yaml"
8+
- id: trailing-whitespace
9+
name: "[file - format] trim trailing whitespace"
10+
args: [ --markdown-linebreak-ext=md ]
11+
- id: check-added-large-files
1112
name: "[file - check] large file"
1213
args: [ --maxkb=5000 ]
13-
- id: check-docstring-first
14+
- id: check-docstring-first
1415
name: "[py - check] docstring first"
1516
files: /examples
1617
types : [file, python ]
17-
- id: check-json
18+
- id: check-json
1819
name: "[json - check] validate json"
19-
- id: check-merge-conflict
20+
- id: check-merge-conflict
2021
name: "[git - check] merge conflict"
21-
- id: debug-statements
22+
- id: debug-statements
2223
name: "[py - check] debug statements"
23-
- id: detect-private-key
24+
- id: detect-private-key
2425
name: "[cred - check] private keys"
25-
- id: fix-encoding-pragma
26+
- id: fix-encoding-pragma
2627
name: "[file - format] coding pragma"
2728
args: [ --remove ]
28-
- id: mixed-line-ending
29+
- id: mixed-line-ending
2930
name: "[file - format] mixed line ending"
3031
args: [ --fix=auto ]
31-
- id: pretty-format-json
32+
- id: pretty-format-json
3233
name: "[json - format] pretty json"
3334
args: [ --autofix,
3435
--indent=4,
3536
--no-sort-keys ]
36-
- id: requirements-txt-fixer
37+
- id: requirements-txt-fixer
3738
name: "[reqs - format] fix requirements.txt"
38-
- id: check-yaml
39+
- id: check-yaml
3940
name: "[yaml - check] validate yaml"
40-
- repo: https://github.com/PyCQA/docformatter
41-
rev: v1.4
42-
hooks:
43-
- id: docformatter
44-
name: "[py - format] docformatter"
45-
args: [ -i, --wrap-summaries, "0" ]
41+
# - repo: https://github.com/pre-commit/mirrors-isort
42+
# rev: v5.10.1
43+
# hooks:
44+
# - id: isort
45+
# name: "[py - format] isort"
46+
- repo: https://github.com/PyCQA/docformatter
47+
rev: v1.4
48+
hooks:
49+
- id: docformatter
50+
name: "[py - format] docformatter"
51+
args: [ -i, --wrap-summaries, "0" ]
4652

47-
- repo: https://github.com/PyCQA/pydocstyle
48-
rev: 6.1.1
49-
hooks:
50-
- id: pydocstyle
51-
name: "[py - check] pydocstyle"
52-
files: ^Hapi/
53+
- repo: https://github.com/PyCQA/pydocstyle
54+
rev: 6.1.1
55+
hooks:
56+
- id: pydocstyle
57+
name: "[py - check] pydocstyle"
58+
files: ^Hapi/
5359

54-
- repo: https://gitlab.com/pycqa/flake8
55-
rev: 3.8.4
56-
hooks:
57-
- id: flake8
58-
name: "[py - check] flake8"
59-
language_version: python3.9
60-
exclude: ^(examples/|tests/)
60+
- repo: https://gitlab.com/pycqa/flake8
61+
rev: 4.0.1
62+
hooks:
63+
- id: flake8
64+
name: "[py - check] flake8"
65+
language_version: python3.9
66+
exclude: ^(examples/|tests/)
6167

62-
- repo: https://github.com/psf/black
63-
rev: 22.8.0
64-
hooks:
65-
- id: black
66-
- repo: https://github.com/pre-commit/mirrors-isort
67-
rev: v5.7.0
68-
hooks:
69-
- id: isort
70-
name: "[py - format] isort"
71-
- repo: https://github.com/ambv/black
72-
rev: 22.8.0
73-
hooks:
74-
- id: black
75-
name: "[py - format] black"
76-
language_version: python3.9
68+
#- repo: https://github.com/psf/black
69+
# rev: 22.8.0
70+
# hooks:
71+
# - id: black
72+
- repo: https://github.com/ambv/black
73+
rev: 22.8.0
74+
hooks:
75+
- id: black
76+
name: "[py - format] black"
77+
language_version: python3.9
78+
- repo: https://github.com/lovesegfault/beautysh
79+
rev: v6.2.1
80+
hooks:
81+
- id: beautysh
82+
name: "[bash - format] beautysh"
7783

78-
- repo: local
79-
hooks:
80-
- id: pytest-check
81-
name: pytest-check
82-
entry: pytest -vvv --cov=Hapi
83-
language: system
84-
pass_filenames: false
85-
always_run: true
84+
# pre-commit-shell: Checks shell scripts against shellcheck.
85+
- repo: https://github.com/detailyang/pre-commit-shell
86+
rev: v1.0.6
87+
hooks:
88+
- id: shell-lint
89+
name: "[bash - lint] shell-lint"
90+
91+
- repo: https://github.com/rlindsgaard/pre-commit-commit-msg-hooks
92+
rev: 0.1.0
93+
hooks:
94+
- id: check-description-max-length
95+
name: "[bash - format] check-description-max-length"
96+
- id: check-second-line-empty
97+
name: "[bash - format] check-second-line-empty"
98+
- id: check-summary-capitalized
99+
name: "[bash - format] check-summary-capitalized"
100+
- id: check-summary-imperative
101+
name: "[bash - format] check-summary-imperative"
102+
- id: check-summary-max-length
103+
name: "[bash - format] check-summary-max-length"
104+
- id: check-summary-punctuation
105+
name: "[bash - format] check-summary-punctuation"
106+
107+
- repo: local
108+
hooks:
109+
- id: pytest-check
110+
name: pytest-check
111+
entry: pytest -vvv --cov=Hapi
112+
language: system
113+
pass_filenames: false
114+
always_run: true

.pydocstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pydocstyle]
2-
ignore = D202, D413, D417, D107, D213
2+
ignore = D202, D413, D417, D107, D213, D203

HISTORY.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ History
4040
------------------
4141
* hydraulic model can read chunked big zip file
4242
* fix CI
43-
* fix missing module (saint venant script and module)
43+
* fix missing module (saint venant script and module)
44+
45+
1.6.0 (2023-02-03)
46+
------------------
47+
* all attributes follows snake case naming convention
48+
* refactor all modules with pre-commit
49+
* add smoothDikeLevel, getReach and updateReach
50+
* bump up denpendencies versions
51+
* move un-necessary functions to serapeum-utils

Hapi/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
@author: Mostafa
44
"""
55
try:
6-
from importlib.metadata import PackageNotFoundError, version # type: ignore
6+
from importlib.metadata import PackageNotFoundError # type: ignore
7+
from importlib.metadata import version
78
except ImportError: # pragma: no cover
8-
from importlib_metadata import PackageNotFoundError, version # type: ignore
9+
from importlib_metadata import PackageNotFoundError # type: ignore
10+
from importlib_metadata import version
911

1012

1113
try:
@@ -37,6 +39,7 @@
3739

3840

3941
def configuration(parent_package="", top_path=None):
42+
"""configure."""
4043
from numpy.distutils.misc_util import Configuration
4144

4245
config = Configuration(None, parent_package, top_path)

Hapi/catchment.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@
2727

2828

2929
class Catchment:
30-
"""Catchment. The class include methods to read the meteorological and Spatial inputs of the distributed hydrological model. Catchment class also reads the data of the gauges, it is a super class that has the run subclass, so you need to build the catchment object and hand it as an inpit to the Run class to run the model.
30+
"""Catchment.
3131
32-
methods:
32+
The class include methods to read the meteorological and Spatial inputs of the distributed hydrological model.
33+
Catchment class also reads the data of the gauges, it is a super class that has the run subclass,
34+
so you need to build the catchment object and hand it as an inpit to the Run class to run the model.
35+
36+
Methods
37+
-------
3338
1-readRainfall
3439
2-readTemperature
3540
3-readET
@@ -375,7 +380,9 @@ def readFlowAcc(self, Path: str):
375380
logger.debug("Flow Accmulation input is read successfully")
376381

377382
def readFlowDir(self, Path: str):
378-
"""readFlowDir method reads the flow direction raster.
383+
"""Read Flow Direction.
384+
385+
reads the flow direction raster.
379386
380387
Parameters
381388
----------
@@ -428,7 +435,9 @@ def readFlowDir(self, Path: str):
428435
logger.debug("Flow Direction input is read successfully")
429436

430437
def ReadFlowPathLength(self, Path: str):
431-
"""ReadFlowPathLength method reads the flow path length.
438+
"""Read Flow Path Length method.
439+
440+
reads the flow path length.
432441
433442
Parameters
434443
----------
@@ -981,7 +990,9 @@ def plotHydrograph(
981990
label: str = "",
982991
fmt: str = "%Y-%m-%d",
983992
):
984-
"""plotHydrograph. plot the simulated and gauge hydrograph.
993+
r"""Plot Hydrograph.
994+
995+
plot the simulated and gauge hydrograph.
985996
986997
Parameters
987998
----------
@@ -1143,7 +1154,7 @@ def plotDistributedResults(
11431154
size of the numbers plotted intop of each cells. The default is 8.
11441155
Title : [str], optional
11451156
title of the plot. The default is 'Total Discharge'.
1146-
titlesize : [integer], optional
1157+
title_size : [integer], optional
11471158
title size. The default is 15.
11481159
Backgroundcolorthreshold : [float/integer], optional
11491160
threshold value if the value of the cell is greater, the plotted
@@ -1427,9 +1438,15 @@ def ListAttributes(self):
14271438

14281439

14291440
class Lake:
1430-
"""Lake. Lake class reads the meteorological inputs, and the module to simulate a lake as a lumped model, using a rating curve, the lake and the upstream sub-catchments are going to be considered as one lumped model than result in a discharge input to the lake, the discharge input is going to change the volume of the water in the lake, and from the volume-outflow curve the outflow can be obtained.
1441+
"""Lake.
1442+
1443+
Lake class reads the meteorological inputs, and the module to simulate a lake as a lumped model, using a
1444+
rating curve, the lake and the upstream sub-catchments are going to be considered as one lumped model than
1445+
result in a discharge input to the lake, the discharge input is going to change the volume of the water in
1446+
the lake, and from the volume-outflow curve the outflow can be obtained.
14311447
1432-
methods:
1448+
Methods
1449+
-------
14331450
1- readMeteoData
14341451
2- readParameters
14351452
3- readLumpedModel

Hapi/cli.py

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

Hapi/hapi_warnings.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
"""Custom warning and silencing warnings."""
12
import warnings
23

3-
import numpy as np
4-
54

65
class InstabilityWarning(UserWarning):
76
"""Issued when results may be unstable."""
@@ -13,9 +12,11 @@ class InstabilityWarning(UserWarning):
1312
warnings.simplefilter("always", UserWarning)
1413

1514

16-
def SilenceNumpyWarning():
17-
np.warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
15+
def SilencePandasWarning():
16+
"""Silence pandas future warning."""
17+
warnings.simplefilter(action="ignore", category=FutureWarning)
1818

1919

2020
def SilenceShapelyWarning():
21+
"""Silence Shapely deprecation warning."""
2122
warnings.filterwarnings("ignore", category=DeprecationWarning)

0 commit comments

Comments
 (0)