Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9d4f4d0
Added files
matthew7838 Mar 31, 2026
cf0b1f6
Updated contents
matthew7838 Mar 31, 2026
ed41f3f
Updated contents
matthew7838 Mar 31, 2026
28982d0
Updated contents in soil and field
matthew7838 Mar 31, 2026
73bab5e
Merge 28982d0d0f072a54694b16f611ad488f711b8a9f into 7b090b9c17b481f1c…
matthew7838 Mar 31, 2026
7965cbc
Apply Black Formatting
github-actions[bot] Mar 31, 2026
d70ad03
Added length comparison and tests
matthew7838 Apr 6, 2026
3d4371d
Merge branch 'dev' into crop-field-xvalidation
matthew7838 Apr 6, 2026
3fad6b8
Merge 3d4371d82e22a4cd178eeab872d6639687e6d023 into f794363cc15eba689…
matthew7838 Apr 6, 2026
c8ecd97
Apply Black Formatting
github-actions[bot] Apr 6, 2026
7477e2e
Deleted extra tests
matthew7838 Apr 6, 2026
b3d68b0
Merge remote-tracking branch 'origin/crop-field-xvalidation' into cro…
matthew7838 Apr 6, 2026
4f5abc0
Merge b3d68b0b8dbb9449e6b5533d2a04e2bb9b156b86 into f794363cc15eba689…
matthew7838 Apr 6, 2026
359318a
Apply Black Formatting
github-actions[bot] Apr 6, 2026
3a194a0
Fixed failing tests
matthew7838 Apr 6, 2026
c3177ca
Merge remote-tracking branch 'origin/crop-field-xvalidation' into cro…
matthew7838 Apr 6, 2026
330de4a
Merge c3177ca53e7b5d4e0455a2d1bf2bfe2171184176 into f794363cc15eba689…
matthew7838 Apr 6, 2026
9542c96
Apply Black Formatting
github-actions[bot] Apr 6, 2026
567a665
Update badges on README
matthew7838 Apr 6, 2026
b43737b
Fixed flake8
matthew7838 Apr 6, 2026
822c729
Merge remote-tracking branch 'origin/crop-field-xvalidation' into cro…
matthew7838 Apr 6, 2026
e43e768
Updated changelog.md
matthew7838 Apr 6, 2026
536a8df
Merge e43e768dd5c462503406fd82c0cfd33a8f6e12f6 into f794363cc15eba689…
matthew7838 Apr 6, 2026
5e89527
Apply Black Formatting
github-actions[bot] Apr 6, 2026
c9deb91
Update badges on README
matthew7838 Apr 6, 2026
b42bab7
Merge branch 'dev' into crop-field-xvalidation
matthew7838 Apr 7, 2026
9f22729
Merge b42bab76fb40b712b817590213594a51cb46ddc0 into 472a3fefa4c4fc717…
matthew7838 Apr 7, 2026
1fbe613
Apply Black Formatting
github-actions[bot] Apr 7, 2026
575a16e
Update badges on README
matthew7838 Apr 7, 2026
f3cd227
Addressed PR comments
matthew7838 Apr 7, 2026
a30033e
Merge f3cd2271117c8d3f806f1c8046c564c128341f10 into 472a3fefa4c4fc717…
matthew7838 Apr 7, 2026
c1afdf0
Apply Black Formatting
github-actions[bot] Apr 7, 2026
205a646
Update badges on README
matthew7838 Apr 7, 2026
e946297
Removed unnecessary test
matthew7838 Apr 7, 2026
5746876
Merge e946297d0df1efc3780c12940a33d4732111b3d2 into 472a3fefa4c4fc717…
matthew7838 Apr 7, 2026
400b4bf
Apply Black Formatting
github-actions[bot] Apr 7, 2026
124f810
Update badges on README
matthew7838 Apr 7, 2026
3586492
Removed flake8 errors
matthew7838 Apr 7, 2026
0ff17a8
Merge remote-tracking branch 'origin/crop-field-xvalidation' into cro…
matthew7838 Apr 7, 2026
d69ba2b
Merge branch 'dev' into crop-field-xvalidation
matthew7838 Apr 7, 2026
9c4b84e
Merge d69ba2b17c98949019c2acf59194fb2011839166 into 53349675447bf39b6…
matthew7838 Apr 7, 2026
516e03a
Apply Black Formatting
github-actions[bot] Apr 7, 2026
f691b20
Update badges on README
matthew7838 Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions RUFAS/data_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,6 @@ def extract_value_by_key_list(
>>> DataValidator.extract_value_by_key_list(example_data, var_path)
'straw'
"""

for key in variable_path:
if isinstance(data, list) and 0 <= int(key) < len(data):
data = data[int(key)]
Expand Down Expand Up @@ -1748,6 +1747,9 @@ def __init__(self) -> None:
"is_of_type": lambda left, right, eager_termination: self._evaluate_is_type(left, right, eager_termination),
"is_null": lambda left, _right, _eager_termination: self._evaluate_is_null(left),
"regex": lambda left, right, _eager_termination: self._evaluate_regex(left, right),
"is_equal_length": lambda left, right, _eager_termination: self._evaluate_equal_data_length(
left, right, _eager_termination
),
}

def cross_validate_data(
Expand Down Expand Up @@ -2170,6 +2172,25 @@ def _validate_relationship(self, relationship: Any, eager_termination: bool) ->
else:
return True

def _evaluate_equal_data_length(self, left_hand_value: Any, right_hand_value: Any, eager_termination: bool) -> bool:
"""Evaluates if data lengths matches."""
if not (isinstance(left_hand_value, list) and isinstance(right_hand_value, list)):
self._event_logs.append(
{
"error": "Invalid data length validation",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the error message that is logged, should it be more specific? for example, "Invalid data length validation: X and Y must have equal lengths" or something.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great suggestion, I agree, and this issue seems like the case for most evaluation methods. However, I think we should have an issue/PR dedicated to this. I will create an issue.

"message": "Both data have to be list type to validate their length.",
"info_map": {
"class": self.__class__.__name__,
"function": self._evaluate_equal_data_length.__name__,
},
}
)
if eager_termination:
raise ValueError("Cross-validation error: Invalid type comparison.")
return False
else:
return len(left_hand_value) == len(right_hand_value)

def _evaluate_equal_condition(self, left_hand_value: Any, right_hand_value: Any) -> bool:
"""Evaluates equal condition."""
return bool(left_hand_value == right_hand_value)
Expand All @@ -2184,7 +2205,6 @@ def _evaluate_is_null(self, left_hand_value: Any) -> bool:

def _evaluate_is_type(self, left_hand_value: Any, data_type: Any, eager_termination: bool) -> bool:
"""Evaluates the if_type condition"""
# TODO: Remove these type checks when cross validation inputs' validation is implemented - issue #2615
if not isinstance(data_type[0], str):
self._event_logs.append(
{
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ v1.0.0
- [2921](https://github.com/RuminantFarmSystems/RuFaS/pull/2921) - [minor change] [OutputManager][NoInputChange] [NoOutputChange] Override incorrect fill type for complex data structure data padding.
- [2924](https://github.com/RuminantFarmSystems/RuFaS/pull/2924) - [minor change] [NoInputChange] [NoOutputChange] Updated advance purchase allowance to prevent excessive warnings for example run.
- [2929](https://github.com/RuminantFarmSystems/RuFaS/pull/2929) - [minor change] [GraphGenerator] [NoInputChange] [NoOutputChange] Sanitizes non-numerical data sent to graph generator to allow graphing to occur despite.
- [2916](https://github.com/RuminantFarmSystems/RuFaS/pull/2916) - [minor change] [Corss Validation] [NoInputChange] [NoOutputChange] Added cross validation rules for the Crop and Soil module.
- [2925](https://github.com/RuminantFarmSystems/RuFaS/pull/2925) - [minor change] [NoInputChange] [NoOutputChange] Fix the `graph_and_report` option in report_generation.py.
- [2907](https://github.com/RuminantFarmSystems/RuFaS/pull/2907) - [minor change] [NoInputChange] [OutputChange] Fix the FarmGrownFeed Emissions unit issue. The mirror issue of [Fix FarmGrownFeed Emissions Unit on test #2908](https://github.com/RuminantFarmSystems/MASM/pull/2908) to update `dev`.


### v1.0.0

- [2081](https://github.com/RuminantFarmSystems/RuFaS/pull/2081) - [minor change] [Crop & Soil] Break down the `_setup_field()` function in `FieldManager`.
Expand Down
2 changes: 1 addition & 1 deletion input/data/crop/example_alf_corn_silage_rotation.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"crop_schedules":
[

{
"crop_species": "corn_silage",
"planting_days": [
Expand Down
Loading