-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55d9819
commit 4e15d80
Showing
9 changed files
with
175 additions
and
168 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import xarray as xr | ||
from tikon.central import Módulo, SimulMódulo, Modelo, Exper, Parcela | ||
from tikon.central.res import Resultado | ||
from tikon.result import Obs | ||
from tikon.utils import EJE_TIEMPO, EJE_PARC | ||
|
||
f_inic = '2000-01-01' | ||
|
||
crds = {'eje 1': ['a', 'b'], 'eje 2': ['x', 'y', 'z']} | ||
|
||
|
||
class Res(Resultado): | ||
|
||
def __init__(símismo, sim, coords, vars_interés): | ||
coords = {**crds, **coords} | ||
super().__init__(sim, coords, vars_interés) | ||
|
||
nombre = 'res' | ||
unids = None | ||
|
||
|
||
class SimulMóduloValid(SimulMódulo): | ||
resultados = [Res] | ||
|
||
def incrementar(símismo, paso, f): | ||
super().incrementar(paso, f) | ||
símismo.poner_valor('res', 1, rel=True) | ||
|
||
|
||
class MóduloValid(Módulo): | ||
nombre = 'módulo' | ||
cls_simul = SimulMóduloValid | ||
|
||
|
||
obs = Obs( | ||
mód='módulo', var='res', datos=xr.DataArray( | ||
np.arange(10), | ||
coords={EJE_TIEMPO: pd.date_range(f_inic, periods=10, freq='D')}, dims=[EJE_TIEMPO] | ||
).expand_dims(crds).expand_dims({EJE_PARC: ['parcela']}) | ||
) | ||
|
||
exper = Exper('exper', Parcela('parcela'), obs=obs) | ||
modelo = Modelo(MóduloValid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import unittest | ||
|
||
from tikon.result import proc | ||
|
||
from .rcrs.modelo_valid import modelo, exper | ||
|
||
|
||
class PruebaValid(unittest.TestCase): | ||
@unittest.skip('implementar') | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.res = modelo.simular('valid', exper) | ||
|
||
def test_valid(símismo): | ||
pass | ||
valid = símismo.res.validar() | ||
símismo.assertDictEqual(valid.criterios, {'ens': 1.0}) | ||
|
||
def test_criterios(símismo): | ||
crits = [ | ||
proc.r2, proc.rcep, proc.rcnep, proc.corresp, proc.ekg, proc.log_p, | ||
proc.r2_percentiles, proc.rcnep_percentiles | ||
] | ||
valids = símismo.res.validar(proc=crits) | ||
símismo.assertSetEqual(set(valids.criterios), {cr.__name__ for cr in crits}) | ||
|
||
def test_nombres_criterios(símismo): | ||
crits = {'R cuadrado': proc.r2, 'otro nombre': proc.rcep} | ||
valids = símismo.res.validar(proc=crits) | ||
símismo.assertSetEqual(set(valids.criterios), set(crits)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.