hestia-earth-models 0.74.14__py3-none-any.whl → 0.74.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/config/Site.json +11 -3
- hestia_earth/models/emepEea2019/fuelCombustion_utils.py +21 -21
- hestia_earth/models/hestia/landOccupationDuringCycle.py +9 -27
- hestia_earth/models/hestia/soilClassification.py +314 -0
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +5 -15
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +5 -15
- hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py +5 -39
- hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +5 -5
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +6 -21
- hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +4 -5
- hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +5 -5
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +17 -46
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +10 -10
- hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +4 -19
- hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +0 -9
- hestia_earth/models/log.py +71 -1
- hestia_earth/models/mocking/search-results.json +1 -1
- hestia_earth/models/utils/blank_node.py +12 -4
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/RECORD +28 -25
- tests/models/ecoalimV9/test_cycle.py +2 -2
- tests/models/hestia/test_soilClassification.py +72 -0
- tests/models/ipcc2019/test_organicCarbonPerHa_utils.py +4 -48
- tests/models/test_log.py +128 -0
- {hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/top_level.txt +0 -0
|
@@ -27,6 +27,7 @@ from hestia_earth.utils.tools import (
|
|
|
27
27
|
from hestia_earth.utils.lookup_utils import (
|
|
28
28
|
is_model_siteType_allowed,
|
|
29
29
|
is_model_product_id_allowed,
|
|
30
|
+
is_model_measurement_id_allowed,
|
|
30
31
|
is_siteType_allowed,
|
|
31
32
|
is_site_measurement_id_allowed,
|
|
32
33
|
is_product_id_allowed,
|
|
@@ -121,12 +122,14 @@ def _module_term_id(term_id: str, module):
|
|
|
121
122
|
def _run_model_required(model: str, term_id: str, data: dict, skip_logs: bool = False):
|
|
122
123
|
siteType_allowed = is_model_siteType_allowed(model, term_id, data)
|
|
123
124
|
product_id_allowed = is_model_product_id_allowed(model, term_id, data)
|
|
125
|
+
site_measurement_id_allowed = is_model_measurement_id_allowed(model, term_id, data)
|
|
124
126
|
|
|
125
|
-
run_required = all([siteType_allowed, product_id_allowed])
|
|
127
|
+
run_required = all([siteType_allowed, product_id_allowed, site_measurement_id_allowed])
|
|
126
128
|
if not skip_logs:
|
|
127
129
|
debugValues(data, model=model, term=term_id,
|
|
128
130
|
run_required=run_required,
|
|
129
131
|
siteType_allowed=siteType_allowed,
|
|
132
|
+
site_measurement_id_allowed=site_measurement_id_allowed,
|
|
130
133
|
product_id_allowed=product_id_allowed)
|
|
131
134
|
return run_required
|
|
132
135
|
|
|
@@ -147,15 +150,16 @@ def _run_required(model: str, term_id: str, data: dict):
|
|
|
147
150
|
# model is only used for logs here, skip logs if model not provided
|
|
148
151
|
if model:
|
|
149
152
|
debugValues(data, model=model, term=term_id,
|
|
153
|
+
# logging this for the model would cause issues parsing statuses
|
|
154
|
+
**({} if model.endswith('NotRelevant') else {
|
|
155
|
+
'run_required': run_required
|
|
156
|
+
}),
|
|
150
157
|
siteType_allowed=siteType_allowed,
|
|
151
158
|
site_measurement_id_allowed=site_measurement_id_allowed,
|
|
152
159
|
product_id_allowed=product_id_allowed,
|
|
153
160
|
product_termType_allowed=product_termType_allowed,
|
|
154
161
|
input_id_allowed=input_id_allowed,
|
|
155
162
|
input_termType_allowed=input_termType_allowed)
|
|
156
|
-
# logging this for the model would cause issues parsing statuses
|
|
157
|
-
if not model.endswith('NotRelevant'):
|
|
158
|
-
debugValues(data, model=model, term=term_id, run_required=run_required)
|
|
159
163
|
return run_required
|
|
160
164
|
|
|
161
165
|
|
|
@@ -1206,6 +1210,10 @@ def split_node_by_dates(node: dict) -> list[dict]:
|
|
|
1206
1210
|
)
|
|
1207
1211
|
|
|
1208
1212
|
|
|
1213
|
+
def split_nodes_by_dates(nodes: list[dict]) -> list[dict]:
|
|
1214
|
+
return non_empty_list(flatten(split_node_by_dates(node) for node in nodes))
|
|
1215
|
+
|
|
1216
|
+
|
|
1209
1217
|
def group_nodes_by_year_and_month(
|
|
1210
1218
|
nodes: list[dict],
|
|
1211
1219
|
default_node_duration: int = 1,
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.74.
|
|
1
|
+
VERSION = '0.74.15'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.74.
|
|
3
|
+
Version: 0.74.15
|
|
4
4
|
Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
|
|
5
5
|
Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
|
|
6
6
|
Author: HESTIA Team
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.6
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: hestia-earth-schema<34.0.0,>=33.5.0
|
|
15
|
-
Requires-Dist: hestia-earth-utils>=0.15.
|
|
15
|
+
Requires-Dist: hestia-earth-utils>=0.15.16
|
|
16
16
|
Requires-Dist: CurrencyConverter==0.16.8
|
|
17
17
|
Requires-Dist: haversine>=2.7.0
|
|
18
18
|
Requires-Dist: pydash
|
|
@@ -2,10 +2,10 @@ hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
|
|
|
2
2
|
hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
|
|
3
3
|
hestia_earth/models/cache_nodes.py,sha256=CqcTkvT0SQw-MKExUJgM3wDRt2sgdxgVYb6ylNnfC4I,5423
|
|
4
4
|
hestia_earth/models/cache_sites.py,sha256=0TK08ewVobQkXQ-qph_uB_mfoOhEqcPr4KKwlPWgUKs,6439
|
|
5
|
-
hestia_earth/models/log.py,sha256=
|
|
5
|
+
hestia_earth/models/log.py,sha256=CGQw2VGbGzVw0ezjlzejTFFUpaHvTED2meLFDW589eo,6362
|
|
6
6
|
hestia_earth/models/preload_requests.py,sha256=-eb4TA4m-A4bLcdAwbKqr3TIsDteVSXhJGCp95mQCew,2504
|
|
7
7
|
hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
|
|
8
|
-
hestia_earth/models/version.py,sha256=
|
|
8
|
+
hestia_earth/models/version.py,sha256=vO9Eir4oHyHd47pkxODdM0pYKudLMviS6FXpd_kDsSI,20
|
|
9
9
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
|
10
10
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=FraWAl06a8OSqbAiHYYLv9e4fYZkVw42S9wikfjeTdw,4377
|
|
11
11
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=qRkDqpEt3WwleMfHdxMi2nezLmCAxa1TlJZ0IPHDTtI,2584
|
|
@@ -39,7 +39,7 @@ hestia_earth/models/cml2001NonBaseline/eutrophicationPotentialIncludingFateAvera
|
|
|
39
39
|
hestia_earth/models/cml2001NonBaseline/terrestrialAcidificationPotentialExcludingFate.py,sha256=JAzphWh_hY437frP0WLobRjnysMsESNcCaNthvCnGd8,966
|
|
40
40
|
hestia_earth/models/config/Cycle.json,sha256=3QSThmSDNw0dDREXKnHnxyi1Jb8yCMprTmdjI2HcSlI,61355
|
|
41
41
|
hestia_earth/models/config/ImpactAssessment.json,sha256=X_CgEB1m8M4uEubhvcgQSovwMwuwSSTFWfkTXM6tChU,61069
|
|
42
|
-
hestia_earth/models/config/Site.json,sha256=
|
|
42
|
+
hestia_earth/models/config/Site.json,sha256=ygHgsrrBHKlj7gY7p_9lGXOGPNFWjZnfnnCHkeLhdOM,14992
|
|
43
43
|
hestia_earth/models/config/__init__.py,sha256=7ZqOGd4dO2Stonte6fbktVZqbY7vp8Ls_LifgofCu8I,3009
|
|
44
44
|
hestia_earth/models/config/run-calculations.json,sha256=e3nJ4M6CP1iFzfv8ou_ZUFbFxYkDxJgwuNDXTm4PBDc,615
|
|
45
45
|
hestia_earth/models/config/trigger-calculations.json,sha256=3dmn2bRuj6QEtSTOLdIy31ho7thgUXyDsnqZzPV9rAQ,623
|
|
@@ -116,7 +116,7 @@ hestia_earth/models/edip2003/__init__.py,sha256=nyB0CI2gNmRAXj-203aJHQMmETYhcY-d
|
|
|
116
116
|
hestia_earth/models/edip2003/ozoneDepletionPotential.py,sha256=GF9IeaZ_fC9HMYy5GT4gk67RQZLZrdoBZmEdmEgAiYI,908
|
|
117
117
|
hestia_earth/models/emepEea2019/__init__.py,sha256=l90-pWrqIzt1ap1WNk0gF4iZeF5_TSG62hE83bIi4rQ,412
|
|
118
118
|
hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py,sha256=f59-XXhUlPw8L80Q9TATkNZf5Pw9LJlofZWfVJNIL9E,814
|
|
119
|
-
hestia_earth/models/emepEea2019/fuelCombustion_utils.py,sha256=
|
|
119
|
+
hestia_earth/models/emepEea2019/fuelCombustion_utils.py,sha256=ZsQmJZybPQrAtsULOmEKfrSed3wasTvLxSbfnPfARtU,4124
|
|
120
120
|
hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py,sha256=6IJSNDMXSeuf9_XGmEll8LxusYnEzVR3WadoVj999j8,860
|
|
121
121
|
hestia_earth/models/emepEea2019/nh3ToAirExcreta.py,sha256=DssSjl_Kug9jE5laqJs9X4xOdOrJBnsXSnk-uA_anyE,2153
|
|
122
122
|
hestia_earth/models/emepEea2019/nh3ToAirFuelCombustion.py,sha256=wbruN-aO3Cj8FCaHbXxlom2AYm_7Jef113EbkXHhj4w,814
|
|
@@ -214,7 +214,7 @@ hestia_earth/models/hestia/inorganicFertiliser.py,sha256=S0LyeoWfczSllGu6js6BORV
|
|
|
214
214
|
hestia_earth/models/hestia/irrigatedTypeUnspecified.py,sha256=3qKc7lUOfwiCEfM0MALih3UCAWFnWiHwHk7ocxxF7O0,1855
|
|
215
215
|
hestia_earth/models/hestia/landCover.py,sha256=eg43qTmsKiraPFwfgtHGScJHt_pCNtakc_iurKkUqwo,11914
|
|
216
216
|
hestia_earth/models/hestia/landCover_utils.py,sha256=QbDJIKWQb9ggDIxq0s8ipRHDK7Lvi-Ak68PBpNrdy74,29647
|
|
217
|
-
hestia_earth/models/hestia/landOccupationDuringCycle.py,sha256=
|
|
217
|
+
hestia_earth/models/hestia/landOccupationDuringCycle.py,sha256=76TbZrSVxEArozUA5Bg6MY5e8UVN5cR4yb3J-DwYEbE,8975
|
|
218
218
|
hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py,sha256=Bd8rD4ioiXvlKCTtYva_Cj3yqIgi2ykeVmCDtjgeY4A,1202
|
|
219
219
|
hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py,sha256=yWbnkjvV87M8lUcSR5nxJGunX3Ne3wdVvBMR2b1K_Sc,1200
|
|
220
220
|
hestia_earth/models/hestia/liveAnimal.py,sha256=LhPlAJUVFDwUlKMLaznFidgc8woD4kAeUSUMXlg3fRI,3872
|
|
@@ -247,6 +247,7 @@ hestia_earth/models/hestia/salineWater.py,sha256=6P0L24tD0-r4VoFt0Uh8djiMgtivGAe
|
|
|
247
247
|
hestia_earth/models/hestia/seed_emissions.py,sha256=UbWTnfI76FRX9XSno09bxVSBKxKkuMv6zU7xEyVpVWk,12454
|
|
248
248
|
hestia_earth/models/hestia/slope.py,sha256=2LdcRvRecUkwmlGVqWBQIeaYfRMvsSWKfS9hWvV_DbU,1160
|
|
249
249
|
hestia_earth/models/hestia/slopeLength.py,sha256=-EK4Kwh2MwFqdRyDWNl4O6zoA4Dz7QcD0RwdlTTaC_E,1166
|
|
250
|
+
hestia_earth/models/hestia/soilClassification.py,sha256=HUYqlxHslS1UjBizEynR3iiQLZaESQNNf08wic_PIFc,9852
|
|
250
251
|
hestia_earth/models/hestia/soilMeasurement.py,sha256=_-3Ex9Lr3e7tseQ530b3axC4svTOQ47dY7vEkLMCNYo,7084
|
|
251
252
|
hestia_earth/models/hestia/stockingDensityAnimalHousingAverage.py,sha256=seqIDyRefjFKaznXTZMaMov7fF_0DGiUij_UAEwP65g,1743
|
|
252
253
|
hestia_earth/models/hestia/temperatureAnnual.py,sha256=ja2ts1YGTL5BSh-ccZFWnE6OxPq1B1I2Kw0Kb8XGO2Y,1959
|
|
@@ -297,24 +298,24 @@ hestia_earth/models/ipcc2013ExcludingFeedbacks/gwp100.py,sha256=Mv__KZMzP7cvl_rU
|
|
|
297
298
|
hestia_earth/models/ipcc2013IncludingFeedbacks/__init__.py,sha256=VJ16KIGQQHybzZiTvu3mpZy_3j0xcd06RHHCfPrCMgU,427
|
|
298
299
|
hestia_earth/models/ipcc2013IncludingFeedbacks/gwp100.py,sha256=XyeEZZN_sxxSqcJY19HkTAAB13q-ybif8e_QsD0xyO0,916
|
|
299
300
|
hestia_earth/models/ipcc2019/__init__.py,sha256=LdRpu8KbEc-MroIwXfKDjfj-xbgmfUYgctjKVvtpRfQ,409
|
|
300
|
-
hestia_earth/models/ipcc2019/aboveGroundBiomass.py,sha256=
|
|
301
|
+
hestia_earth/models/ipcc2019/aboveGroundBiomass.py,sha256=fdkpLZ34WTXZxeKaCBHstxDP4sqkJFwWkEmKOqG2VJA,20138
|
|
301
302
|
hestia_earth/models/ipcc2019/aboveGroundCropResidueTotal.py,sha256=oG7j8K0bqPGqIaw35wlwHEEz1xI_o5qTwABp5YVTtaA,3466
|
|
302
|
-
hestia_earth/models/ipcc2019/belowGroundBiomass.py,sha256=
|
|
303
|
+
hestia_earth/models/ipcc2019/belowGroundBiomass.py,sha256=NOp8WaX1NJk0TawwJRGzdrrpc0-1xW2JUlACRtbW0-c,19143
|
|
303
304
|
hestia_earth/models/ipcc2019/belowGroundCropResidue.py,sha256=M9--7akmPWo7gfxEYnKobsJ0HyDzfAzRxLmrCt3Pg1Y,3505
|
|
304
|
-
hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py,sha256=
|
|
305
|
+
hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py,sha256=1N4dsiRY_pyLvPcq3g8uBiAiVwSScLFocS9FFBxRW1s,12580
|
|
305
306
|
hestia_earth/models/ipcc2019/biomass_utils.py,sha256=NkTPGMl-0tqvhUZKZ1rxW0XTBnZOvgFJki_IPzEEyu0,15796
|
|
306
307
|
hestia_earth/models/ipcc2019/carbonContent.py,sha256=XhXDu6DRQxANBsRsCEgw4f0UJDOgWsvhVyEwK1-4YT0,7263
|
|
307
308
|
hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py,sha256=n1hG-p67BTXkJATvX1em6255WY0mJxk7SojzBwebtnQ,3385
|
|
308
309
|
hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py,sha256=piSmwF1G5mYO32_WWncq_k5PaJ0EWrYguVEl_vns6-Q,12167
|
|
309
310
|
hestia_earth/models/ipcc2019/ch4ToAirExcreta.py,sha256=5Ujxec6f5lFZaPbKRcg7XMUBmyYeWcMdaR3ZQ6iStrQ,6489
|
|
310
311
|
hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py,sha256=3173-WEI_4TpvPdl55VNpmXANPoM92o8hTqcGidj7ds,9979
|
|
311
|
-
hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py,sha256=
|
|
312
|
+
hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py,sha256=0NX2SGFVXcT2bi-icSc-AiscLI2QqgVsOmWV05nOHpM,9552
|
|
312
313
|
hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py,sha256=HaqqfVT19OTp943QpPkdxv6R8eDSYmEddHq9J2fN6b0,4570
|
|
313
314
|
hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py,sha256=4kQ0jAnvr1tNS12_FCJpD3K5f9SCkMheNheXu2evaKE,4094
|
|
314
315
|
hestia_earth/models/ipcc2019/co2ToAirBiocharStockChange.py,sha256=ngZcV_0Gyowccx5PXhYF56Q7YyxcvmfOjgXkU-Odyyw,3762
|
|
315
|
-
hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=
|
|
316
|
+
hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=Y9l9DZs9xsojplhFMLWdwNsvnzyMKijX_Y7fvFn3vwA,60998
|
|
316
317
|
hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=5ciisz0wFbjlwfshDzMlvRIjvw_E8NsphX0IulzVD3A,2479
|
|
317
|
-
hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py,sha256=
|
|
318
|
+
hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py,sha256=MZGAlJEGs7DiiFw40tGzx-e8ZMze7sgC-R2X-FZl3aE,7613
|
|
318
319
|
hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py,sha256=Ti1koM7k_fV7iWklSFngYaBpAERf3yOaUM5BTbWmDxs,4106
|
|
319
320
|
hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=IInWDQCfMQWd6rXDRZnLMQlaQGghVQJcwFSGtRMdkzo,3871
|
|
320
321
|
hestia_earth/models/ipcc2019/croppingDuration.py,sha256=AEOnzVc8mbx0kHpm5BIEiXr1zP0IDUl9qKktNlgURnk,3080
|
|
@@ -333,7 +334,7 @@ hestia_earth/models/ipcc2019/n2OToAirNaturalVegetationBurningIndirect.py,sha256=
|
|
|
333
334
|
hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserDirect.py,sha256=RSNdJIVgnGs6Qe3SkR9yLYkwVIOjVPBUhqk7P29pv3I,4195
|
|
334
335
|
hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py,sha256=1izTtLx0iFsK5yRzbxoy_kN6oflHTfBEj-sFXBERAnU,1380
|
|
335
336
|
hestia_earth/models/ipcc2019/n2OToAirOrganicSoilBurningIndirect.py,sha256=6nyMMrhpK5ZaG_Be0ivJB6MSdbYYg6RD67appp1wJiU,1301
|
|
336
|
-
hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py,sha256=
|
|
337
|
+
hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py,sha256=tQvOTcqq642WWXs6xMExvwr-2Qb1L8HHHtOSm20vsrs,5807
|
|
337
338
|
hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationIndirect.py,sha256=lXMSAIvWBsNf6TTbYIPTu_uMSBBgk_JDO6S6r630yvg,1321
|
|
338
339
|
hestia_earth/models/ipcc2019/n2OToAir_indirect_emissions_utils.py,sha256=gsxEwd_WF4ZgUIGb8H1Co6AME_eIpCWPvSCNfDJCKbo,4467
|
|
339
340
|
hestia_earth/models/ipcc2019/nh3ToAirInorganicFertiliser.py,sha256=UGojWa9GJRf_JQxfvgX8ywwfoL7N-9FGDF7h679iLNM,4336
|
|
@@ -343,14 +344,14 @@ hestia_earth/models/ipcc2019/no3ToGroundwaterCropResidueDecomposition.py,sha256=
|
|
|
343
344
|
hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py,sha256=BV7kdeGlDbSQASBtYZuLNTQktrteaMWGJzIbG97flH0,4319
|
|
344
345
|
hestia_earth/models/ipcc2019/no3ToGroundwaterInorganicFertiliser.py,sha256=zww-PDlLdz3XbrlXfW7F8nWzP3Iud1uLW-mRo8HZf2o,3250
|
|
345
346
|
hestia_earth/models/ipcc2019/no3ToGroundwaterOrganicFertiliser.py,sha256=AHCYaj_al-cLFtvWHhxZLlrZfpjIyWg2rKR435qqGxM,3184
|
|
346
|
-
hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py,sha256=
|
|
347
|
+
hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py,sha256=MSg_43Pybi5Tf2RVlSv_2pCBk2RSV6PiwoYlEm2Z0Hg,33455
|
|
347
348
|
hestia_earth/models/ipcc2019/noxToAirInorganicFertiliser.py,sha256=nBBiKzGMUYtHkU49AKBxQ7OdD61cb9_Ehe7ixFWKHR4,4336
|
|
348
349
|
hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=yONOR8ppiOXQlPPz68GQ2_3MFzvnOQTJTHpJ956ubW0,4008
|
|
349
|
-
hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=
|
|
350
|
+
hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=qYR1iB95Uz841xPe727ZYUtrRhg_Unbktf1YEjZHqyU,8000
|
|
350
351
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py,sha256=IfXans2CZLagxfr8A0GRxCF2pMu9-ZV8DjuUludaeRQ,79084
|
|
351
352
|
hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py,sha256=2kw9bhkR4o4ZSeC4ZFEIEe7OxZvE7Ft1f3Et94YPl3c,69231
|
|
352
|
-
hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py,sha256=
|
|
353
|
-
hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py,sha256=
|
|
353
|
+
hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py,sha256=DDP3nY-QVRU10FkFihNbnF66-Oa6O6Tkn7ycnetN110,9924
|
|
354
|
+
hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py,sha256=S5XaM7142_ShxFFXPZ4HaOdofRzMYucWc--5udxuin4,5361
|
|
354
355
|
hestia_earth/models/ipcc2019/pastureGrass.py,sha256=V1PRJ17dYw0p9lvuyRVFuYzJrpmNOs0FjhNUXOuUkyU,10202
|
|
355
356
|
hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=so5AFrr_0eKXkUoyBpYhHgSXhTQ5z2XADahm2At4RR0,14285
|
|
356
357
|
hestia_earth/models/ipcc2019/utils.py,sha256=s3khA5nJ0rpFsrwWoIGW0y3OYrYA5Iw2GTxN86gO_K8,5890
|
|
@@ -471,7 +472,7 @@ hestia_earth/models/linkedImpactAssessment/utils.py,sha256=uxRu5thfTDGpCNIuv3Nak
|
|
|
471
472
|
hestia_earth/models/mocking/__init__.py,sha256=-mJ_zrVWZSGc3awWW2YJfXAK3Nku77sAUgmmFa99Xmo,733
|
|
472
473
|
hestia_earth/models/mocking/build_mock_search.py,sha256=p15ccEUmkmLp1RiGNznxMz3OFHbI8P1-29ExuohiQN8,1355
|
|
473
474
|
hestia_earth/models/mocking/mock_search.py,sha256=uvklojTAbjDI7Jw43jGAUDcTHk1R3A3CWiYBJZI6rao,1493
|
|
474
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
|
475
|
+
hestia_earth/models/mocking/search-results.json,sha256=Y38gcp5sPNm7P-Bd2dUk6XMpJGUKQAZNCOJRj37ZD70,103984
|
|
475
476
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
|
476
477
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=FoiRk-bULfC9VbhT7L-wgjehrUkG_74XiG2WnW1Rc-U,2402
|
|
477
478
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=r7Wqo5v29NrKfhDd0g1QCharR2k6H5XFyAsKZ6pvYKY,2321
|
|
@@ -618,7 +619,7 @@ hestia_earth/models/utils/aggregated.py,sha256=IJ24J79bbLTOek5VV9SDxbv2PuFxoyrzE
|
|
|
618
619
|
hestia_earth/models/utils/animalProduct.py,sha256=M5IunAKGY6oZv3j1Ascl34ywyeLWApqOIlBzbtlA2FE,721
|
|
619
620
|
hestia_earth/models/utils/aquacultureManagement.py,sha256=dxrbC1Xf140cohxTbSw6TxLAnAASWTdNZwBBam4yQnw,171
|
|
620
621
|
hestia_earth/models/utils/background_emissions.py,sha256=hCQQ5W50xqniLvPaZu__bZpK9A16ymH7rhd8KijzWLQ,6957
|
|
621
|
-
hestia_earth/models/utils/blank_node.py,sha256=
|
|
622
|
+
hestia_earth/models/utils/blank_node.py,sha256=nUCnH0Tzpg5Lbf8yF1I1HgDM5DoWw9Vc_HuD_QAL20Y,57027
|
|
622
623
|
hestia_earth/models/utils/cache_sources.py,sha256=MBkrPpjwNiC4ApDjeYVHZjWBbpvAerXRDrMHpjasAZ0,377
|
|
623
624
|
hestia_earth/models/utils/completeness.py,sha256=1FtDzl1dQ-AZ4nCn1vfGqR4RK3yHItfkksVqsJzIWR0,1256
|
|
624
625
|
hestia_earth/models/utils/constant.py,sha256=DmB3VVuoh7Pz2QDBJqiUG6yAML2i0fOy1BPuPHmhT1w,3442
|
|
@@ -679,6 +680,7 @@ tests/models/test_cache_nodes.py,sha256=lSSoBGFVXpNv_TePSetls6QbnhfLC7dNLmfiFqT6
|
|
|
679
680
|
tests/models/test_cache_sites.py,sha256=eZkbgAhfA-67GhPgE4lk8byHnYvX2Ate1KPsE6jH1-c,2954
|
|
680
681
|
tests/models/test_config.py,sha256=wMzRHRtu_H61haAQpT-UtN6nxOQw-JAFrAf-jiIWkiQ,4578
|
|
681
682
|
tests/models/test_emissionNotRelevant.py,sha256=TsIV47lpn7joLGx-LlPVqWbshcLf2c6pUvB3FZwLvwY,1023
|
|
683
|
+
tests/models/test_log.py,sha256=AuhnN-G-CrvHu8fGOEsFKwhR7ZXwZsveYr7JT8bSMmg,4059
|
|
682
684
|
tests/models/test_resourceUseNotRelevant.py,sha256=z1zY3pJdffongIsBJaLB7WToBrMiE4wYuHSsAbGEJ7w,983
|
|
683
685
|
tests/models/test_utils.py,sha256=Caa9sCyz25egPrSlu7FQhjXD2vNcQW9gea_ppUYOsEs,186
|
|
684
686
|
tests/models/agribalyse2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -770,7 +772,7 @@ tests/models/data/test_hestiaAggregatedData.py,sha256=m72rayilqxzJ3SzamDdIQ7ZVAP
|
|
|
770
772
|
tests/models/deRuijterEtAl2010/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
771
773
|
tests/models/deRuijterEtAl2010/test_nh3ToAirCropResidueDecomposition.py,sha256=kS1nUBVohOSCb386g6Wq7iVclmx0haekUDYo7VQ4NCA,2030
|
|
772
774
|
tests/models/ecoalimV9/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
773
|
-
tests/models/ecoalimV9/test_cycle.py,sha256=
|
|
775
|
+
tests/models/ecoalimV9/test_cycle.py,sha256=NMQqd3vYRvbL6WAodJsJNo6YnW0z67-VtG3vEIK7RYY,747
|
|
774
776
|
tests/models/ecoalimV9/test_impact_assessment.py,sha256=5h9jx7wSPah_FvRDyT-NEejRKlXc5ZmtVucHfkxVMQ8,862
|
|
775
777
|
tests/models/ecoinventV3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
776
778
|
tests/models/ecoinventV3/test_cycle.py,sha256=jOX-1Xmp8rFzGammioA3zPwPq-w5CS3GeEJ5vUoX0JU,2030
|
|
@@ -908,6 +910,7 @@ tests/models/hestia/test_salineWater.py,sha256=a-JNyzcAPlP-VAQnJbJ6igYWkZ0GCJT_C
|
|
|
908
910
|
tests/models/hestia/test_seed_emissions.py,sha256=dCUuJBkhwNFBhhcypQN7eMqrWZ9iGCnypoidO5DfQYw,921
|
|
909
911
|
tests/models/hestia/test_slope.py,sha256=ahlhaznJXuU4jxBMZXAEdWUA8Am7WyF4GvNvyX1SdxM,658
|
|
910
912
|
tests/models/hestia/test_slopeLength.py,sha256=O3KXO8mze_PzW1IzV3KPO2YK5QN-a9FWhCkcIG-TWtI,670
|
|
913
|
+
tests/models/hestia/test_soilClassification.py,sha256=B4HXGXBXmQKdC5a5bTzxetuFJGkLh4Rz-pgDXUFhSrI,3594
|
|
911
914
|
tests/models/hestia/test_soilMeasurement.py,sha256=hLJ1wlYIopFzDd4bSuHV64vR2jo4v4Js7Rgso71BX7o,4381
|
|
912
915
|
tests/models/hestia/test_stockingDensityAnimalHousingAverage.py,sha256=ZKLKU75FoYHiKIXqDuXPpfPN06InLA8ZHJFtkkLBhOY,1311
|
|
913
916
|
tests/models/hestia/test_temperatureAnnual.py,sha256=vYqcZu2efQgWfCKXTCTse_9trmMzmBwPz6IN81NzRoI,994
|
|
@@ -1003,7 +1006,7 @@ tests/models/ipcc2019/test_noxToAirOrganicFertiliser.py,sha256=LR5pjV5vRbgSSQAw8
|
|
|
1003
1006
|
tests/models/ipcc2019/test_organicCarbonPerHa.py,sha256=g_uOqzj6EiyvoAZRpd4PakMYQ7Vfn0QiDGLCTVz92A8,15607
|
|
1004
1007
|
tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py,sha256=6DzuqTllZ_Zv3Xuic-3ZIaIik1rYd2eQZk7nysbLCxk,20687
|
|
1005
1008
|
tests/models/ipcc2019/test_organicCarbonPerHa_tier_2.py,sha256=VYNtsuFDURzqvKH1_5_6_lSQrqTxWnLdopN5ULfrzMg,5486
|
|
1006
|
-
tests/models/ipcc2019/test_organicCarbonPerHa_utils.py,sha256=
|
|
1009
|
+
tests/models/ipcc2019/test_organicCarbonPerHa_utils.py,sha256=jK7wO0dLKODwp_fwY-kp8cfWsDJ1MVXxasGUfqbVFkA,813
|
|
1007
1010
|
tests/models/ipcc2019/test_pastureGrass.py,sha256=6B8ZmuI1w4rA4wGduWx0l6e0BgGz8b2knTUIcT0GDOg,2725
|
|
1008
1011
|
tests/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1009
1012
|
tests/models/ipcc2019/animal/test_fatContent.py,sha256=Emp8jGudRGA_dJaLMR5Jxsv3Gc57rMAnP0CDqswrmlM,775
|
|
@@ -1295,8 +1298,8 @@ tests/orchestrator/strategies/run/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
|
1295
1298
|
tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py,sha256=K4xg4UAXfNhSaLyknKVPO7MGBF44Z_gD7CuZ_pe28gU,3512
|
|
1296
1299
|
tests/orchestrator/strategies/run/test_add_key_if_missing.py,sha256=hKwvk1ohcBVnQUCTiDhRW99J0xEa29BpwFi1KC0yWLE,329
|
|
1297
1300
|
tests/orchestrator/strategies/run/test_always.py,sha256=w5-Dhp6yLzgZGAeMRz3OrqZbbAed9gZ1O266a3z9k7w,134
|
|
1298
|
-
hestia_earth_models-0.74.
|
|
1299
|
-
hestia_earth_models-0.74.
|
|
1300
|
-
hestia_earth_models-0.74.
|
|
1301
|
-
hestia_earth_models-0.74.
|
|
1302
|
-
hestia_earth_models-0.74.
|
|
1301
|
+
hestia_earth_models-0.74.15.dist-info/LICENSE,sha256=TD25LoiRJsA5CPUNrcyt1PXlGcbUGFMAeZoBcfCrCNE,1154
|
|
1302
|
+
hestia_earth_models-0.74.15.dist-info/METADATA,sha256=4AtIGfEZBnRYTvkOa0N9lH7i7jNOr1JhKFIAJ0kg4cM,4039
|
|
1303
|
+
hestia_earth_models-0.74.15.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1304
|
+
hestia_earth_models-0.74.15.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
|
1305
|
+
hestia_earth_models-0.74.15.dist-info/RECORD,,
|
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
import json
|
|
3
3
|
from unittest.mock import patch
|
|
4
4
|
|
|
5
|
-
from tests.utils import fixtures_path, fake_new_emission
|
|
5
|
+
from tests.utils import fixtures_path, fake_new_emission, sort_background_emissions
|
|
6
6
|
from hestia_earth.models.ecoalimV9.cycle import MODEL, run
|
|
7
7
|
|
|
8
8
|
class_path = f"hestia_earth.models.{MODEL}.cycle"
|
|
@@ -17,6 +17,6 @@ def test_run(*args):
|
|
|
17
17
|
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
18
18
|
expected = json.load(f)['emissions']
|
|
19
19
|
|
|
20
|
-
result = run(cycle)
|
|
20
|
+
result = sort_background_emissions(run(cycle))
|
|
21
21
|
print(json.dumps(result, indent=2))
|
|
22
22
|
assert result == expected
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from os.path import isfile
|
|
3
|
+
from pytest import mark
|
|
4
|
+
from unittest.mock import patch, MagicMock
|
|
5
|
+
|
|
6
|
+
from hestia_earth.models.hestia.soilClassification import MODEL, run, _should_run
|
|
7
|
+
|
|
8
|
+
from tests.utils import fake_new_measurement, fixtures_path
|
|
9
|
+
|
|
10
|
+
NAME = "soilClassification"
|
|
11
|
+
|
|
12
|
+
class_path = f"hestia_earth.models.{MODEL}.{NAME}"
|
|
13
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{NAME}"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _load_fixture(file_name: str, default=None):
|
|
17
|
+
path = f"{fixtures_folder}/{file_name}.jsonld"
|
|
18
|
+
if isfile(path):
|
|
19
|
+
with open(path, encoding="utf-8") as f:
|
|
20
|
+
return json.load(f)
|
|
21
|
+
return default
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# subfolder, should_run
|
|
25
|
+
PARAMS_SHOULD_RUN = [
|
|
26
|
+
("single-org-with-date", True), # Single histosol measurement, with date
|
|
27
|
+
("single-org-without-date", True), # Single histosol measurement, no date
|
|
28
|
+
("multiple-org-values-single-node-with-dates", True), # Multiple histosol measurements, with dates, single node # noqa: E501
|
|
29
|
+
("multiple-org-values-multiple-nodes-with-dates", True), # Multiple histosol measurements, with dates, two nodes
|
|
30
|
+
("multiple-org-values-multiple-nodes-without-dates", True), # Multiple histosol measurements, no dates
|
|
31
|
+
("multiple-org-values-multiple-nodes-mixed-dates", True), # Multiple histosol measurements, inconsistent dates
|
|
32
|
+
("single-min-equal-100", True), # No histosol measurement, mineral measurements equal 100% # noqa: E501
|
|
33
|
+
("single-min-less-than-100", True), # No histosol measurement, other soilType measurements do not equal 100% # noqa: E501
|
|
34
|
+
("no-measurements", True), # No histosol measurement, no other soilType measurements -> return default # noqa: E501
|
|
35
|
+
("multiple-org-values-multiple-depths", True), # Multiple histosol measurements, with different depths
|
|
36
|
+
("org-and-min-less-than-100", True), # Total soil types do not equal 100%
|
|
37
|
+
("non-standard-depths", True), # Non-standard depths
|
|
38
|
+
("min-with-dates-less-than-100-org-without-dates", True), # Mineral soils with dates, histosols without
|
|
39
|
+
("min-with-dates-equal-100-org-without-dates", True), # Mineral soils with dates (equal 100%), histosols without # noqa: E501
|
|
40
|
+
("0-30-without-dates-0-50-with-dates", True), # No dates for 0-30, dates for 0-50
|
|
41
|
+
("no-dates-no-depth", True), # No dates, no depths
|
|
42
|
+
("mixed-depths-choose-standard", True), # Mix of standard, non-standard and missing depths -> choose standard depths # noqa: E501
|
|
43
|
+
("mixed-depths-choose-non-standard", True), # Mix of non-standard and missing depths -> choose non-standard depths # noqa: E501
|
|
44
|
+
]
|
|
45
|
+
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@mark.parametrize("subfolder, expected", PARAMS_SHOULD_RUN, ids=IDS_SHOULD_RUN)
|
|
49
|
+
def test_should_run(
|
|
50
|
+
subfolder: str,
|
|
51
|
+
expected: bool
|
|
52
|
+
):
|
|
53
|
+
site = _load_fixture(f"{subfolder}/site", {})
|
|
54
|
+
|
|
55
|
+
result, *_ = _should_run(site)
|
|
56
|
+
assert result == expected
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@mark.parametrize("subfolder", PARAMS_RUN)
|
|
63
|
+
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
64
|
+
def test_run(
|
|
65
|
+
_mock_new_measurement: MagicMock,
|
|
66
|
+
subfolder: str
|
|
67
|
+
):
|
|
68
|
+
site = _load_fixture(f"{subfolder}/site", {})
|
|
69
|
+
expected = _load_fixture(f"{subfolder}/result", {})
|
|
70
|
+
|
|
71
|
+
result = run(site)
|
|
72
|
+
assert result == expected
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
from pytest import mark
|
|
2
2
|
|
|
3
|
-
from hestia_earth.models.ipcc2019.organicCarbonPerHa_utils import
|
|
4
|
-
format_bool, format_bool_list, format_enum, format_number, format_number_list, IpccSoilCategory
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@mark.parametrize(
|
|
9
|
-
"value, expected",
|
|
10
|
-
[
|
|
11
|
-
(True, "True"),
|
|
12
|
-
(False, "False"),
|
|
13
|
-
([], "False"),
|
|
14
|
-
("str", "True"),
|
|
15
|
-
(None, "False")
|
|
16
|
-
],
|
|
17
|
-
ids=["True", "False", "list", "str", "None"]
|
|
18
|
-
)
|
|
19
|
-
def test_format_bool(value, expected):
|
|
20
|
-
assert format_bool(value) == expected
|
|
3
|
+
from hestia_earth.models.ipcc2019.organicCarbonPerHa_utils import format_bool_list, format_float_list
|
|
21
4
|
|
|
22
5
|
|
|
23
6
|
@mark.parametrize(
|
|
@@ -25,7 +8,7 @@ def test_format_bool(value, expected):
|
|
|
25
8
|
[
|
|
26
9
|
([True, True, False], "True True False"),
|
|
27
10
|
([], "None"),
|
|
28
|
-
(["Yes", "No", ""], "
|
|
11
|
+
(["Yes", "No", ""], "None None None"),
|
|
29
12
|
(None, "None")
|
|
30
13
|
],
|
|
31
14
|
ids=["list", "empty list", "list[str]", "None"]
|
|
@@ -37,34 +20,7 @@ def test_format_bool_list(value, expected):
|
|
|
37
20
|
@mark.parametrize(
|
|
38
21
|
"value, expected",
|
|
39
22
|
[
|
|
40
|
-
(
|
|
41
|
-
("str", "None"),
|
|
42
|
-
(None, "None")
|
|
43
|
-
],
|
|
44
|
-
ids=["Enum", "str", "None"]
|
|
45
|
-
)
|
|
46
|
-
def test_format_enum(value, expected):
|
|
47
|
-
assert format_enum(value) == expected
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@mark.parametrize(
|
|
51
|
-
"value, expected",
|
|
52
|
-
[
|
|
53
|
-
(3.141592653, "3.1"),
|
|
54
|
-
(0, "0.0"),
|
|
55
|
-
("20", "None"),
|
|
56
|
-
(None, "None")
|
|
57
|
-
],
|
|
58
|
-
ids=["float", "zero", "str", "None"]
|
|
59
|
-
)
|
|
60
|
-
def test_format_number(value, expected):
|
|
61
|
-
assert format_number(value) == expected
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@mark.parametrize(
|
|
65
|
-
"value, expected",
|
|
66
|
-
[
|
|
67
|
-
([3.14, 31.4, 314], "3.1 31.4 314.0"),
|
|
23
|
+
([3.14, 31.4, 314], "3.1 31.4 314"),
|
|
68
24
|
([], "None"),
|
|
69
25
|
(["Yes", "No", ""], "None None None"),
|
|
70
26
|
(None, "None")
|
|
@@ -72,4 +28,4 @@ def test_format_number(value, expected):
|
|
|
72
28
|
ids=["list", "empty list", "list[str]", "None"]
|
|
73
29
|
)
|
|
74
30
|
def test_format_number_list(value, expected):
|
|
75
|
-
assert
|
|
31
|
+
assert format_float_list(value) == expected
|
tests/models/test_log.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from numpy import array
|
|
3
|
+
from pytest import mark
|
|
4
|
+
|
|
5
|
+
from hestia_earth.models.log import (
|
|
6
|
+
format_bool, format_decimal_percentage, format_enum, format_float, format_int, format_nd_array, format_str
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@mark.parametrize(
|
|
11
|
+
"value, kwargs, expected",
|
|
12
|
+
[
|
|
13
|
+
(True, {}, "True"),
|
|
14
|
+
(False, {}, "False"),
|
|
15
|
+
([], {}, "None"),
|
|
16
|
+
("str", {}, "None"),
|
|
17
|
+
(None, {}, "None"),
|
|
18
|
+
(None, {"default": "Override"}, "Override")
|
|
19
|
+
],
|
|
20
|
+
ids=["True", "False", "list", "str", "None", "None w/ default"]
|
|
21
|
+
)
|
|
22
|
+
def test_format_bool(value, kwargs, expected):
|
|
23
|
+
assert format_bool(value, **kwargs) == expected
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@mark.parametrize(
|
|
27
|
+
"value, kwargs, expected",
|
|
28
|
+
[
|
|
29
|
+
(3.141592653, {}, "314.159 pct"),
|
|
30
|
+
(0, {}, "0 pct"),
|
|
31
|
+
("20", {}, "None"),
|
|
32
|
+
(None, {}, "None"),
|
|
33
|
+
(3.141592653, {"unit": "kg"}, "314.159 kg"),
|
|
34
|
+
(3.141592653, {"ndigits": 4}, "314.1593 pct"),
|
|
35
|
+
(None, {"default": "Override"}, "Override"),
|
|
36
|
+
],
|
|
37
|
+
ids=["float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
|
|
38
|
+
)
|
|
39
|
+
def test_format_decimal_percentage(value, kwargs, expected):
|
|
40
|
+
assert format_decimal_percentage(value, **kwargs) == expected
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class TestEnum(Enum):
|
|
44
|
+
WITH_LEGAL_CHARS = "with legal chars"
|
|
45
|
+
WITH_RESERVED_CHARS = "with_reserved_chars"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@mark.parametrize(
|
|
49
|
+
"value, kwargs, expected",
|
|
50
|
+
[
|
|
51
|
+
(TestEnum.WITH_LEGAL_CHARS, {}, TestEnum.WITH_LEGAL_CHARS.value),
|
|
52
|
+
(TestEnum.WITH_RESERVED_CHARS, {}, "with-reserved-chars"),
|
|
53
|
+
("str", {}, "None"),
|
|
54
|
+
(None, {}, "None"),
|
|
55
|
+
(None, {"default": "Override"}, "Override")
|
|
56
|
+
],
|
|
57
|
+
ids=["Enum w/ legal chars", "Enum w/ illegal chars", "str", "None", "None w/ default"]
|
|
58
|
+
)
|
|
59
|
+
def test_format_enum(value, kwargs, expected):
|
|
60
|
+
assert format_enum(value, **kwargs) == expected
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@mark.parametrize(
|
|
64
|
+
"value, kwargs, expected",
|
|
65
|
+
[
|
|
66
|
+
(3.141592653, {}, "3.142"),
|
|
67
|
+
(0, {}, "0"),
|
|
68
|
+
("20", {}, "None"),
|
|
69
|
+
(None, {}, "None"),
|
|
70
|
+
(3.141592653, {"unit": "kg"}, "3.142 kg"),
|
|
71
|
+
(3.141592653, {"ndigits": 4}, "3.1416"),
|
|
72
|
+
(None, {"default": "Override"}, "Override"),
|
|
73
|
+
],
|
|
74
|
+
ids=["float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
|
|
75
|
+
)
|
|
76
|
+
def test_format_float(value, kwargs, expected):
|
|
77
|
+
assert format_float(value, **kwargs) == expected
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@mark.parametrize(
|
|
81
|
+
"value, kwargs, expected",
|
|
82
|
+
[
|
|
83
|
+
(3.141592653, {}, "3"),
|
|
84
|
+
(0, {}, "0"),
|
|
85
|
+
("20", {}, "None"),
|
|
86
|
+
(None, {}, "None"),
|
|
87
|
+
(3.141592653, {"unit": "kg"}, "3 kg"),
|
|
88
|
+
(None, {"default": "Override"}, "Override")
|
|
89
|
+
],
|
|
90
|
+
ids=["float", "zero", "str", "None", "float w/ unit", "None w/ default"]
|
|
91
|
+
)
|
|
92
|
+
def test_format_int(value, kwargs, expected):
|
|
93
|
+
assert format_int(value, **kwargs) == expected
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@mark.parametrize(
|
|
97
|
+
"value, kwargs, expected",
|
|
98
|
+
[
|
|
99
|
+
(array(3.141592653), {}, "3.142 ± 0.0"),
|
|
100
|
+
(array([1, 2, 3, 4]), {}, "2.5 ± 1.118"),
|
|
101
|
+
(array([[11, 12, 13, 14], [21, 22, 23, 24]]), {}, "17.5 ± 5.123"),
|
|
102
|
+
(3.141592653, {}, "3.142"),
|
|
103
|
+
(0, {}, "0"),
|
|
104
|
+
("20", {}, "None"),
|
|
105
|
+
(None, {}, "None"),
|
|
106
|
+
(array(3.141592653), {"unit": "kg"}, "3.142 ± 0.0 kg"),
|
|
107
|
+
(array(3.141592653), {"ndigits": 4}, "3.1416 ± 0.0"),
|
|
108
|
+
(None, {"default": "Override"}, "Override"),
|
|
109
|
+
],
|
|
110
|
+
ids=["scalar", "1d", "2d", "float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
|
|
111
|
+
)
|
|
112
|
+
def test_format_nd_array(value, kwargs, expected):
|
|
113
|
+
assert format_nd_array(value, **kwargs) == expected
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@mark.parametrize(
|
|
117
|
+
"value, kwargs, expected",
|
|
118
|
+
[
|
|
119
|
+
("string", {}, "string"),
|
|
120
|
+
("some_reserved:chars,get=replaced", {}, "some-reserved-chars-get-replaced"),
|
|
121
|
+
([], {}, "None"),
|
|
122
|
+
(None, {}, "None"),
|
|
123
|
+
(None, {"default": "Override"}, "Override")
|
|
124
|
+
],
|
|
125
|
+
ids=["legal chars", "illegal chars", "list", "None", "None w/ default"]
|
|
126
|
+
)
|
|
127
|
+
def test_format_str(value, kwargs, expected):
|
|
128
|
+
assert format_str(value, **kwargs) == expected
|
|
File without changes
|
|
File without changes
|
{hestia_earth_models-0.74.14.dist-info → hestia_earth_models-0.74.15.dist-info}/top_level.txt
RENAMED
|
File without changes
|