Skip to content

Commit

Permalink
Merge pull request #118 from Serapieum-of-alex/refactor-rename
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
MAfarrag authored Feb 2, 2023
2 parents 92f333d + bc1aec0 commit 0a688aa
Show file tree
Hide file tree
Showing 64 changed files with 6,169 additions and 5,054 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = E203, E266, E501, W503, C901, E722, E731, W605, E712, F841, D202
ignore = E203, E266, E501, W503, C901, E722, E731, W605, E712, F841, D202, D203
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:
- name: Generate coverage report
run: |
python -m pytest -vvv --cov=Hapi --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
151 changes: 90 additions & 61 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,85 +1,114 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
name: "[py - check] validate yaml"
- id: trailing-whitespace
name: "[file - format] trim trailing whitespace"
args: [ --markdown-linebreak-ext=md ]
- id: check-added-large-files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer
name: "[py - check] validate yaml"
- id: trailing-whitespace
name: "[file - format] trim trailing whitespace"
args: [ --markdown-linebreak-ext=md ]
- id: check-added-large-files
name: "[file - check] large file"
args: [ --maxkb=5000 ]
- id: check-docstring-first
- id: check-docstring-first
name: "[py - check] docstring first"
files: /examples
types : [file, python ]
- id: check-json
- id: check-json
name: "[json - check] validate json"
- id: check-merge-conflict
- id: check-merge-conflict
name: "[git - check] merge conflict"
- id: debug-statements
- id: debug-statements
name: "[py - check] debug statements"
- id: detect-private-key
- id: detect-private-key
name: "[cred - check] private keys"
- id: fix-encoding-pragma
- id: fix-encoding-pragma
name: "[file - format] coding pragma"
args: [ --remove ]
- id: mixed-line-ending
- id: mixed-line-ending
name: "[file - format] mixed line ending"
args: [ --fix=auto ]
- id: pretty-format-json
- id: pretty-format-json
name: "[json - format] pretty json"
args: [ --autofix,
--indent=4,
--no-sort-keys ]
- id: requirements-txt-fixer
- id: requirements-txt-fixer
name: "[reqs - format] fix requirements.txt"
- id: check-yaml
- id: check-yaml
name: "[yaml - check] validate yaml"
- repo: https://github.com/PyCQA/docformatter
rev: v1.4
hooks:
- id: docformatter
name: "[py - format] docformatter"
args: [ -i, --wrap-summaries, "0" ]
# - repo: https://github.com/pre-commit/mirrors-isort
# rev: v5.10.1
# hooks:
# - id: isort
# name: "[py - format] isort"
- repo: https://github.com/PyCQA/docformatter
rev: v1.4
hooks:
- id: docformatter
name: "[py - format] docformatter"
args: [ -i, --wrap-summaries, "0" ]

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
name: "[py - check] pydocstyle"
files: ^Hapi/
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
name: "[py - check] pydocstyle"
files: ^Hapi/

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
name: "[py - check] flake8"
language_version: python3.9
exclude: ^(examples/|tests/)
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
name: "[py - check] flake8"
language_version: python3.9
exclude: ^(examples/|tests/)

- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
name: "[py - format] isort"
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
name: "[py - format] black"
language_version: python3.9
#- repo: https://github.com/psf/black
# rev: 22.8.0
# hooks:
# - id: black
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
name: "[py - format] black"
language_version: python3.9
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh
name: "[bash - format] beautysh"

- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest -vvv --cov=Hapi
language: system
pass_filenames: false
always_run: true
# pre-commit-shell: Checks shell scripts against shellcheck.
- repo: https://github.com/detailyang/pre-commit-shell
rev: v1.0.6
hooks:
- id: shell-lint
name: "[bash - lint] shell-lint"

- repo: https://github.com/rlindsgaard/pre-commit-commit-msg-hooks
rev: 0.1.0
hooks:
- id: check-description-max-length
name: "[bash - format] check-description-max-length"
- id: check-second-line-empty
name: "[bash - format] check-second-line-empty"
- id: check-summary-capitalized
name: "[bash - format] check-summary-capitalized"
- id: check-summary-imperative
name: "[bash - format] check-summary-imperative"
- id: check-summary-max-length
name: "[bash - format] check-summary-max-length"
- id: check-summary-punctuation
name: "[bash - format] check-summary-punctuation"

- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest -vvv --cov=Hapi
language: system
pass_filenames: false
always_run: true
2 changes: 1 addition & 1 deletion .pydocstyle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pydocstyle]
ignore = D202, D413, D417, D107, D213
ignore = D202, D413, D417, D107, D213, D203
10 changes: 9 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ History
------------------
* hydraulic model can read chunked big zip file
* fix CI
* fix missing module (saint venant script and module)
* fix missing module (saint venant script and module)

1.6.0 (2023-02-03)
------------------
* all attributes follows snake case naming convention
* refactor all modules with pre-commit
* add smoothDikeLevel, getReach and updateReach
* bump up denpendencies versions
* move un-necessary functions to serapeum-utils
7 changes: 5 additions & 2 deletions Hapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
@author: Mostafa
"""
try:
from importlib.metadata import PackageNotFoundError, version # type: ignore
from importlib.metadata import PackageNotFoundError # type: ignore
from importlib.metadata import version
except ImportError: # pragma: no cover
from importlib_metadata import PackageNotFoundError, version # type: ignore
from importlib_metadata import PackageNotFoundError # type: ignore
from importlib_metadata import version


try:
Expand Down Expand Up @@ -37,6 +39,7 @@


def configuration(parent_package="", top_path=None):
"""configure."""
from numpy.distutils.misc_util import Configuration

config = Configuration(None, parent_package, top_path)
Expand Down
33 changes: 25 additions & 8 deletions Hapi/catchment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@


class Catchment:
"""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.
"""Catchment.
methods:
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.
Methods
-------
1-readRainfall
2-readTemperature
3-readET
Expand Down Expand Up @@ -375,7 +380,9 @@ def readFlowAcc(self, Path: str):
logger.debug("Flow Accmulation input is read successfully")

def readFlowDir(self, Path: str):
"""readFlowDir method reads the flow direction raster.
"""Read Flow Direction.
reads the flow direction raster.
Parameters
----------
Expand Down Expand Up @@ -428,7 +435,9 @@ def readFlowDir(self, Path: str):
logger.debug("Flow Direction input is read successfully")

def ReadFlowPathLength(self, Path: str):
"""ReadFlowPathLength method reads the flow path length.
"""Read Flow Path Length method.
reads the flow path length.
Parameters
----------
Expand Down Expand Up @@ -981,7 +990,9 @@ def plotHydrograph(
label: str = "",
fmt: str = "%Y-%m-%d",
):
"""plotHydrograph. plot the simulated and gauge hydrograph.
r"""Plot Hydrograph.
plot the simulated and gauge hydrograph.
Parameters
----------
Expand Down Expand Up @@ -1143,7 +1154,7 @@ def plotDistributedResults(
size of the numbers plotted intop of each cells. The default is 8.
Title : [str], optional
title of the plot. The default is 'Total Discharge'.
titlesize : [integer], optional
title_size : [integer], optional
title size. The default is 15.
Backgroundcolorthreshold : [float/integer], optional
threshold value if the value of the cell is greater, the plotted
Expand Down Expand Up @@ -1427,9 +1438,15 @@ def ListAttributes(self):


class Lake:
"""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.
"""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.
methods:
Methods
-------
1- readMeteoData
2- readParameters
3- readLumpedModel
Expand Down
18 changes: 0 additions & 18 deletions Hapi/cli.py

This file was deleted.

9 changes: 5 additions & 4 deletions Hapi/hapi_warnings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Custom warning and silencing warnings."""
import warnings

import numpy as np


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


def SilenceNumpyWarning():
np.warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
def SilencePandasWarning():
"""Silence pandas future warning."""
warnings.simplefilter(action="ignore", category=FutureWarning)


def SilenceShapelyWarning():
"""Silence Shapely deprecation warning."""
warnings.filterwarnings("ignore", category=DeprecationWarning)
1 change: 1 addition & 0 deletions Hapi/hm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Hydraulic model."""
Loading

0 comments on commit 0a688aa

Please sign in to comment.