techmatters / soil-id-algorithm

GNU Affero General Public License v3.0
1 stars 0 forks source link

bug: algorithm crash in `rank_soils` when passing in empty data #113

Closed shrouxm closed 4 months ago

shrouxm commented 4 months ago

Description

Rank soils crashes when provided with empty data. For example,

    rank_soils(
        lon=-122.126583,
        lat=37.430296,
        list_output_data=list_soils(-122.126583, 37.430296),
        soilHorizon=[],
        horizonDepth=[],
        rfvDepth=[],
        lab_Color=[],
        pSlope=None,
        pElev=None,
        bedrock=None,
        cracks=None,
    )

Steps To Reproduce

  1. Go to URL: [insert URL here]

Expected behavior

No crash.

Actual behavior

Following traceback:

 # Check if user has entered horizon data
>       if p_hz_data.empty or p_bottom_depth.bottom_depth.le(0).any():
E       AttributeError: 'NoneType' object has no attribute 'empty'

soil_id/us_soil.py:1750: AttributeError

Additional context

I think this is an easy fix.