Skip to content

Commit

Permalink
Feature/tomlconfig (#9)
Browse files Browse the repository at this point in the history
* fix: moved 2024 paper to folder

* chore: move build to pyproject

* doc: fixed README

* doc: fixed LICENSE

* chore: fixed pyproject

* chore: move build to pyproject

* doc: fixed README

* chore: fixed pyproject

* chore: fixed version

* chore: fixed pyproject
  • Loading branch information
jlerat authored Dec 5, 2024
1 parent 9177c93 commit b348387
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 3,054 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
show_missing = True
omit =
src/pyquasoare/__init__.py
src/pyquasoare/__version__.py

12 changes: 6 additions & 6 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
- name: Create conda environment if needed
run: |
source $CONDA/etc/profile.d/conda.sh
conda env create -f env_mini_v2.yml
conda env create -f env_pyquasoare.yml
- name : Install hydrodiy package in conda env
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_mini_v2
conda activate env_pyquasoare
cd $GITHUB_WORKSPACE
mkdir -p src
cd src
Expand All @@ -45,7 +45,7 @@ jobs:
- name : Install pygme package in conda env
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_mini_v2
conda activate env_pyquasoare
cd $GITHUB_WORKSPACE
mkdir -p src
cd src
Expand All @@ -57,15 +57,15 @@ jobs:
- name : Install pyquasoare package in conda env
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_mini_v2
conda activate env_pyquasoare
cd $GITHUB_WORKSPACE
echo "--- pyquasoare install : located in $PWD ---"
pip install -e .
- name: Run tests
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_mini_v2
conda activate env_pyquasoare
cd $GITHUB_WORKSPACE
echo "--- pyquasoare test : located in $PWD ---"
pytest --ignore=src/pygme --ignore=src/hydrodiy --doctest-modules src
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Run examples
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_mini_v2
conda activate env_pyquasoare
cd $GITHUB_WORKSPACE
echo "--- pyquasoare examples : located in $PWD ---"
python examples/run_all_examples.py
Expand Down
44 changes: 44 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: pyquasoare
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Julien
family-names: Lerat
email: [email protected]
affiliation: CSIRO
orcid: '0000-0003-4521-8874'
identifiers:
- type: doi
value: 10.5281/zenodo.13928254
repository-code: 'https://github.com/csiro-hydroinformatics/pyquasoare'
url: 'https://github.com/csiro-hydroinformatics/pyquasoare'
abstract: >-
This package implements the Quadratic Solution of the
Approximate Reservoir Equation (QuaSoARe) method.
"Quadratic solution of the approximate reservoir equation
(QUASOARE)", HESS, Submitted.
keywords:
- Differential equation
- Reservoir
- Hydrology
- Rainfall-runoff
license: MIT

references:
- type: article
title: Technical note: Quadratic solution of the approximate reservoir equation (QuaSoARe)
authors:
- family-names: "Lerat"
given-names: "Julien"
orcid: "0000-0003-4521-8874"
year: 2024
journal: "Hydrology and Earth System Sciences"
volume: "in review"
url: "https://egusphere.copernicus.org/preprints/2024/egusphere-2024-3184"
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ piecewise quadratic interpolation following the QuaSoARe method.
This package implements the Quadratic Solution of the Approximate Reservoir
Equation (QuaSoARe) method described in the following paper:
Lerat, J. (2024),
"Quadratic solution of the approximate reservoir equation (QUASOARE)", HESS, Submitted.
"Technical note: Quadratic solution of the approximate reservoir equation (QuaASOARE)", HESS, Submitted.

# Installation
- Create a suitable python environment. We recommend using [miniconda](https://docs.conda.io/projects/miniconda/en/latest/) combined with the environment specification provided in the [env\_mini2.yml] (env_mini2.yml) file in this repository.
- Create a suitable python environment. We recommend using [miniconda](https://docs.conda.io/projects/miniconda/en/latest/) combined with the environment specification provided in the [env_pyquasoare.yml] (env_pyquasoare.yml) file in this repository.
- Git clone this repository and run `pip install .`

# Basic use
Expand Down Expand Up @@ -84,7 +84,9 @@ for iax, ax in enumerate(axs):
plt.show()
```

# License
The source code and documentation of the pyquasoare package is licensed under the
[MIT license](LICENSE.txt).
## Attribution
This project is licensed under the [MIT License](LICENSE), which allows for free use, modification, and distribution of the code under the terms of the license.

For proper citation of this project, please refer to the [CITATION.cff](CITATION.cff) file, which provides guidance on
how to cite the software and relevant publications.

2 changes: 1 addition & 1 deletion env_mini_v2.yml → env_pyquasoare.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: env_mini_v2
name: env_pyquasoare
channels:
- conda-forge
- defaults
Expand Down
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = [
"setuptools >= 64",
"cython >= 3.0.10",
"numpy >= 1.20.0"
]
build-backend = "setuptools.build_meta"

[project]
name = "pyquasoare"
authors = [{name = "Julien Lerat, CSIRO Environment", email="[email protected]"}]
description = "Solve the approximate reservoir equation using the QuaSoARe method"
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["differential equation", "reservoir", "dynamic system", "store", "routing", "rainfall-runoff", "hydrology"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Programming Language :: Python 3",
"Programming Language :: C",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Hydrology"
]
requires-python = ">= 3.8"
dependencies = [
"hydrodiy",
"numpy >= 1.20.0",
"scipy >= 1.0.0",
"pandas >= 2.0.0"
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/csiro-hydroinformatics/pyquasoare"
Repository = "https://github.com/csiro-hydroinformatics/pyquasoare"

[tool.pytest.ini_options]
testpaths = [
"tests"
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "pyquasoare.__version__"}
21 changes: 0 additions & 21 deletions setup.cfg

This file was deleted.

65 changes: 10 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,71 +1,26 @@
#!/usr/bin/env python

import os
import numpy
from pathlib import Path

from setuptools import setup, Extension, find_packages
from setuptools import setup, Extension
from Cython.Build import cythonize

from Cython.Distutils import build_ext

import versioneer

def read(fname):
thisfolder = Path(__file__).resolve().parent
with (thisfolder / fname).open() as fo:
return fo.read()

# C extensions
ext_quasoare=Extension(name="c_pyquasoare",
sources=[
extensions = [
Extension(name="c_pyquasoare",
sources=[
"src/pyquasoare/c_pyquasoare.pyx",
"src/pyquasoare/c_quasoare_utils.c",
"src/pyquasoare/c_quasoare_core.c",
"src/pyquasoare/c_nonlinrouting.c",
"src/pyquasoare/c_gr4jprod.c"
],
extra_cflags=["-O3"],
include_dirs=[numpy.get_include()])

cmdclass = versioneer.get_cmdclass()
cmdclass["build_ext"] = build_ext
],
include_dirs=[numpy.get_include()])
]

# Package config
setup(
name="pyquasoare",
author= "Julien Lerat",
author_email= "[email protected]",
url= "https://github.com/csiro-hydroinformatics/pyquasoare",
download_url= "hhttps://github.com/csiro-hydroinformatics/pyquasoare/tags",
version=versioneer.get_version(),
description= "Solve the approximate reservoir equation using the QuaSoARe method",
long_description= read("README.md"),
packages=find_packages(),
package_dir={"": "src"},
package_data={
"pyquasoare": [
"data/*.csv",
"data/daily/*.zip",
"data/hourly/*.zip"
],
},
install_requires= [
"cython",
"hydrodiy",
"numpy >= 1.8.0",
"scipy (>=0.14.0)",
"pandas >= 0.16"
],
cmdclass=cmdclass,
ext_modules=[ext_quasoare],
classifiers=[
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License"
]
ext_modules=cythonize(extensions, \
compiler_directives={"language_level": 3, "profile": False})
)


7 changes: 2 additions & 5 deletions src/pyquasoare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import importlib

__version__ = "1.2"

def has_c_module(raise_error=True):
name = f"c_pyquasoare"
out = importlib.util.find_spec(name)
Expand All @@ -13,9 +15,4 @@ def has_c_module(raise_error=True):
else:
return False

#from ._version import get_versions
#__version__ = get_versions()['version']
#del get_versions

from . import _version
__version__ = _version.get_versions()['version']
Loading

0 comments on commit b348387

Please sign in to comment.