Skip to content

Commit f1d0b85

Browse files
BESNIER AURELIENRamiALBASHA
BESNIER AURELIEN
authored andcommittedFeb 20, 2025
Fixing test suite + no more warnings
1 parent d719abf commit f1d0b85

9 files changed

+14
-25
lines changed
 

‎src/hydroshoot/energy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def set_local_wind_speed(g, meteo, leaf_lbl_prefix='L') -> dict:
141141
142142
"""
143143
leaves = get_leaves(g, leaf_lbl_prefix)
144-
u = meteo.u[0]
144+
u = meteo.u.iloc[0]
145145
return {vid: u for vid in leaves}
146146

147147

@@ -380,7 +380,7 @@ def force_soil_temperature(meteo):
380380
t_soil = meteo.Tsoil[0]
381381
else:
382382
dt_soil = [3, 3, 3, 3, 3, 3, 3, 3, 10, 15, 20, 20, 20, 20, 20, 15, 6, 5, 4, 3, 3, 3, 3, 3]
383-
t_soil = meteo.Tac[0] + dt_soil[meteo.index.hour[0]]
383+
t_soil = meteo.Tac.iloc[0] + dt_soil[meteo.index.hour[0]]
384384
return t_soil
385385

386386

‎src/hydroshoot/initialisation.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def calc_nitrogen_distribution(g: MTG, gdd_since_budbreak: float, weather: DataF
2626
temperature_base=params.phenology.t_base)
2727

2828
date_beg_sim = params.simulation.date_beg
29-
date_range_last_10_days = date_range(date_beg_sim + timedelta(days=-10), date_beg_sim, freq='H')
29+
date_range_last_10_days = date_range(date_beg_sim + timedelta(days=-10), date_beg_sim, freq='h')
3030
caribu_source, _ = irradiance_distribution(
3131
meteo=weather.loc[date_range_last_10_days, :],
3232
geo_location=params.simulation.geo_location,
@@ -70,7 +70,6 @@ def remove_stem_geometry(g: MTG):
7070
to_remove = [i for i in geom_prop if not g.node(i).label.startswith(('L', 'other', 'soil'))]
7171
[geom_prop.pop(x) for x in to_remove]
7272
g.properties()['geometry'] = geom_prop
73-
pass
7473

7574

7675
def set_photosynthetic_capacity(g: MTG, photo_n_params: dict, deactivation_enthalopy: float, leaf_lbl_prefix: str):
@@ -82,7 +81,6 @@ def set_photosynthetic_capacity(g: MTG, photo_n_params: dict, deactivation_entha
8281
n.TPU25 = photo_n_params['TPU25_N'][0] * nitrogen_content + photo_n_params['TPU25_N'][1]
8382
n.Rd = photo_n_params['Rd_N'][0] * nitrogen_content + photo_n_params['Rd_N'][1]
8483
n.dHd = deactivation_enthalopy
85-
pass
8684

8785

8886
def set_collar_water_potential_function(params: Params, **kwargs) -> Callable:

‎src/hydroshoot/params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def __init__(self, simulation_dict):
9191
self.is_negligible_shoot_resistance = simulation_dict['negligible_shoot_resistance']
9292
self.is_energy_budget = simulation_dict['energy_budget']
9393

94-
self.date_range = date_range(start=self.date_beg, end=self.date_end, freq='H')
95-
self.conv_to_second = {'D': 86.4e3, 'H': 3600., 'T': 60., 'S': 1.}[self.date_range.freqstr]
94+
self.date_range = date_range(start=self.date_beg, end=self.date_end, freq='h')
95+
self.conv_to_second = {'D': 86.4e3, 'h': 3600., 'T': 60., 'S': 1.}[self.date_range.freqstr]
9696
self.conv_to_meter = {'mm': 1.e-3, 'cm': 1.e-2, 'm': 1.}[self.unit_scene_length]
9797
self.geo_location = (self._latitude, self._longitude, self._elevation)
9898

‎src/hydroshoot/soil.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from math import pi, log
2+
import numpy as np
23

34
from hydroshoot import constants as cst
45

@@ -174,7 +175,8 @@ def calc_root_soil_resistance(soil_conductivity: float, rhyzosphere_volume: floa
174175
root_length_density = root_length / rhyzosphere_volume # [m m3]
175176
d = (pi * root_length_density) ** -0.5 # half distance between roots [m]
176177
k = soil_conductivity * 1.e-2 / 86400. * (2 * pi * d * root_length) * cst.water_density # cm d-1 -> kg m-2 s-1
177-
return log(d ** 2 / ((2 * root_radius) ** 2)) / (4 * pi * k) # m2 s kg-1
178+
with np.errstate(divide='ignore'):
179+
return log(d ** 2 / ((2 * root_radius) ** 2)) / (4 * pi * k) # m2 s kg-1
178180

179181

180182
def calc_collar_water_potential(transpiration: float, bulk_soil_water_potential: float, rhyzosphere_volume: float,

‎test/__init__.py

-11
This file was deleted.

‎test/test_energy.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import hydroshoot.energy as energy
55
from hydroshoot.architecture import get_leaves
66
from hydroshoot.energy import set_form_factors_simplified, calc_leaf_temperature, force_soil_temperature
7-
from test.non_regression_data import potted_syrah, meteo
7+
from non_regression_data import potted_syrah, meteo
88

99

1010
def test_pgl_scene():
@@ -47,7 +47,7 @@ def test_form_factors_simplified():
4747
def test_forced_soil_temperature():
4848
met = meteo().iloc[[12], :]
4949
tsoil = force_soil_temperature(met)
50-
assert tsoil == met.Tac[0] + 20
50+
assert tsoil == met.Tac.iloc[0] + 20
5151

5252

5353
def test_leaf_temperature():
@@ -73,4 +73,4 @@ def test_leaf_temperature():
7373
first = list(tleaf.keys())[0]
7474
for vid in tleaf:
7575
assert tleaf[vid] == tleaf[first]
76-
assert tleaf[vid] != met.Tac[0]
76+
assert tleaf[vid] != met.Tac.iloc[0]

‎test/test_hydraulic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from openalea.mtg import traversal
33

44
from hydroshoot import hydraulic, architecture
5-
from test.non_regression_data import potted_syrah
5+
from non_regression_data import potted_syrah
66

77

88
def test_conductivity_max_increases_as_segment_diameter_increases():

‎test/test_irradiance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from numpy.testing import assert_almost_equal
22

33
from hydroshoot.irradiance import irradiance_distribution, hsCaribu, set_optical_properties, e_conv_PPFD
4-
from test.non_regression_data import potted_syrah, meteo
4+
from non_regression_data import potted_syrah, meteo
55

66

77
def test_irradiance_distribution():

‎test/test_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from numpy.testing import assert_array_almost_equal
55

66
from hydroshoot import model
7-
from test import non_regression_data
7+
import non_regression_data
88

99

1010
def test_potted_grapevine():

0 commit comments

Comments
 (0)
Please sign in to comment.