Skip to content

Commit

Permalink
Added new names from #60 as alias in cmf.i and bumped version number
Browse files Browse the repository at this point in the history
  • Loading branch information
philippkraft committed Aug 22, 2018
1 parent 09a5333 commit e279373
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cmf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from .stopwatch import StopWatch


__version__ = '1.3.1'
__compiletime__ = 'Wed Aug 22 10:53:40 2018'
__version__ = '1.4'
__compiletime__ = 'Wed Aug 22 15:25:40 2018'

from .cmf_core import connect_cells_with_flux as __ccwf

Expand Down
6 changes: 6 additions & 0 deletions cmf/cmf_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13879,4 +13879,10 @@ def to_string(self, *args, **kwargs):
# SoluteWaterIntegrator end


ConstantFlux = TechnicalFlux
ConstantStateFlux = statecontrol_connection
WaterBalanceFlux = waterbalance_connection
ConceptualInfiltration = SimpleInfiltration



8 changes: 7 additions & 1 deletion cmf/cmf_core_src/cmf.i
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,11 @@ std::string pyrepr(PyObject* o) {
%include "math/integrators/WaterSoluteIntegrator.h"



%pythoncode {
ConstantFlux = TechnicalFlux
ConstantStateFlux = statecontrol_connection
WaterBalanceFlux = waterbalance_connection
ConceptualInfiltration = SimpleInfiltration
}


56 changes: 34 additions & 22 deletions cmf/cmf_core_src/docstrings.i
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,23 @@ cmf::water::bidirectional_kinematic_exchange::to_string "virtual
std::string to_string() const ";


// File: classcmf_1_1math_1_1_brents_method.xml
%feature("docstring") cmf::math::BrentsMethod "";
// File: classcmf_1_1math_1_1root__finding_1_1_bisect.xml
%feature("docstring") cmf::math::root_finding::Bisect "";

%feature("docstring") cmf::math::BrentsMethod::BrentsMethod "BrentsMethod(double tolerance=1e-12, unsigned int max_iterations=1000)
%feature("docstring") cmf::math::root_finding::Bisect::Bisect "Bisect(double tolerance=1e-12, unsigned int max_iterations=1000) ";

%feature("docstring") cmf::math::root_finding::Bisect::f "virtual
double f(double) const =0 ";


// File: classcmf_1_1math_1_1root__finding_1_1_brents_method.xml
%feature("docstring") cmf::math::root_finding::BrentsMethod "";

%feature("docstring")
cmf::math::root_finding::BrentsMethod::BrentsMethod "BrentsMethod(double tolerance=1e-12, unsigned int max_iterations=1000)
";

%feature("docstring") cmf::math::BrentsMethod::f "virtual double
f(double) const =0 ";
%feature("docstring") cmf::math::root_finding::BrentsMethod::f "virtual double f(double) const =0 ";


// File: classcmf_1_1upslope_1_1_brooks_corey_retention_curve.xml
Expand Down Expand Up @@ -6463,11 +6472,11 @@ const
returns the number of state variables ";


// File: classcmf_1_1math_1_1_brents_method_1_1iteration__error.xml
%feature("docstring") cmf::math::BrentsMethod::iteration_error "";
// File: classcmf_1_1math_1_1root__finding_1_1iteration__error.xml
%feature("docstring") cmf::math::root_finding::iteration_error "";

%feature("docstring")
cmf::math::BrentsMethod::iteration_error::iteration_error "iteration_error(std::string msg) ";
cmf::math::root_finding::iteration_error::iteration_error "iteration_error(std::string msg) ";


// File: classcmf_1_1river_1_1_i_volume_height_function.xml
Expand Down Expand Up @@ -9991,11 +10000,11 @@ Returns the water balance of each vector as a vector.
Replaces slow Python code like: ";


// File: classcmf_1_1math_1_1_brents_method_1_1not__finite__error.xml
%feature("docstring") cmf::math::BrentsMethod::not_finite_error "";
// File: classcmf_1_1math_1_1root__finding_1_1not__finite__error.xml
%feature("docstring") cmf::math::root_finding::not_finite_error "";

%feature("docstring")
cmf::math::BrentsMethod::not_finite_error::not_finite_error "not_finite_error(std::string msg) ";
cmf::math::root_finding::not_finite_error::not_finite_error "not_finite_error(std::string msg) ";


// File: classcmf_1_1water_1_1_null_adsorption.xml
Expand Down Expand Up @@ -13130,10 +13139,10 @@ transp_from_layer(cmf::upslope::SoilLayer::ptr sl, cmf::math::Time t)
";


// File: classcmf_1_1math_1_1_brents_method_1_1sign__error.xml
%feature("docstring") cmf::math::BrentsMethod::sign_error "";
// File: classcmf_1_1math_1_1root__finding_1_1sign__error.xml
%feature("docstring") cmf::math::root_finding::sign_error "";

%feature("docstring") cmf::math::BrentsMethod::sign_error::sign_error
%feature("docstring") cmf::math::root_finding::sign_error::sign_error
"sign_error(std::string msg) ";


Expand Down Expand Up @@ -18252,15 +18261,13 @@ p2) ";


// File: namespacecmf_1_1math.xml
%feature("docstring") cmf::math::get_parallel_threads "int
cmf::math::get_parallel_threads()
%feature("docstring") cmf::math::root_finding::get_parallel_threads "int cmf::math::get_parallel_threads()

Returns the max number of threads used by OpenMP in parallel sections
of the code. ";

%feature("docstring") cmf::math::nash_sutcliffe "double
cmf::math::nash_sutcliffe(const cmf::math::timeseries &model, const
cmf::math::timeseries &observation)
%feature("docstring") cmf::math::root_finding::nash_sutcliffe "double cmf::math::nash_sutcliffe(const cmf::math::timeseries &model,
const cmf::math::timeseries &observation)

Calculates the Nash-Sutcliffe efficiency of a modeled timeseries in
comparison with an observed timeseries.
Expand All @@ -18282,16 +18289,18 @@ steps

:math:`\\\\overline{O}` is the arithmetic mean of observations ";

%feature("docstring") cmf::math::set_parallel_threads "int
cmf::math::set_parallel_threads(int numthreads)
%feature("docstring") cmf::math::root_finding::set_parallel_threads "int cmf::math::set_parallel_threads(int numthreads)

Set the number of threads used by OpenMP in parallel sections of the
code. ";

%feature("docstring") cmf::math::timespan "Time
%feature("docstring") cmf::math::root_finding::timespan "Time
cmf::math::timespan(long long ms) ";


// File: namespacecmf_1_1math_1_1root__finding.xml


// File: namespacecmf_1_1river.xml
%feature("docstring") cmf::river::make_river_gap "double
cmf::river::make_river_gap(Reach::ptr root_reach)
Expand Down Expand Up @@ -18536,6 +18545,9 @@ boundary condition, providing the potential of the lower node. ";
// File: namespacestd.xml
%feature("docstring") std::isfinite "bool std::isfinite(double v) ";

%feature("docstring") std::to_string "std::string std::to_string(T
val) ";


// File: ____init_____8py.xml

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from distutils.sysconfig import customize_compiler
from distutils.command.build_py import build_py

version = '1.3.1'
version = '1.4'
branchversion = version
try:
from pygit2 import Repository
Expand Down
62 changes: 62 additions & 0 deletions test/abstract_fluxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Tests the functionality of the rather abstract connection types
"""
import cmf
import numpy as np
import unittest

def get_project():
p = cmf.project()
w = p.NewStorage('source')
o = p.NewOutlet('out')

return p, w, o


class TestAbstractFluxes(unittest.TestCase):

def test_constant_flux(self):
p, w, o = get_project()
cmf.ConstantFlux(w, o, 1.0, 1.0, cmf.day)
t0 = cmf.Time()

def assert_flux(vol, flux):
w.volume = vol
self.assertAlmostEqual(w.flux_to(o, t0), flux)

for vol, flux in [(3, 1), (2, 1), (1.5, 0.5), (1.0, 0.0), (0.0, 0.0)]:
assert_flux(vol, flux)

def test_constant_state_flux(self):
p, w, o = get_project()
o.is_source = True
cmf.ConstantStateFlux(w, o, 1.0, cmf.day)
t0 = cmf.Time()

def assert_flux(vol, flux):
w.volume = vol
self.assertAlmostEqual(w.flux_to(o, t0), flux)

for vol, flux in [(2, 1), (1, 0), (1.5, 0.5), (0.0, -1.0)]:
assert_flux(vol, flux)

def test_balance_flux(self):
p, w, o = get_project()
i = p.NewNeumannBoundary('input', w)
o.is_source = True
cmf.WaterBalanceFlux(w, o)
t0 = cmf.Time()

def assert_flux(influx, outflux):
i.flux = influx
self.assertAlmostEqual(w.flux_to(o, t0), outflux)

for flux in np.arange(0, 10, 0.1):
assert_flux(flux, flux)


if __name__ == '__main__':
unittest.main()


3 changes: 3 additions & 0 deletions test/reachtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ def test_depth(self):

for a in np.arange(0., 2., 0.01):
self.assertAlmostEquals(cr.get_depth(a), tr.get_depth(a))

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tools/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = cmf
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.3.1
PROJECT_NUMBER = 1.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down

0 comments on commit e279373

Please sign in to comment.