Commit 7729d679 authored by Niklas Selke's avatar Niklas Selke
Browse files

modified the landcover service

parent 0a057809
Pipeline #97104 passed with stages
in 49 seconds
"""serializer for landcover
"""serializer for landcover data
"""
from utils.agg_serializer import GeneralAggSerializer
# serializer classes
class AggSerializer(GeneralAggSerializer):
......
......@@ -26,8 +26,7 @@ class TestViews(TestCase):
def test_LandcoverView(self):
view = LandcoverView()
self.assertEqual(view.min_valid, 1)
self.assertEqual(view.max_valid, 220)
self.assertEqual(view.min_valid, 1.)
self.assertEqual(view.max_valid, 220.)
self.assertTrue(view.AggSerializer is AggSerializer)
self.assertListEqual(view.AGG_ALLOWED, ['maxclass', 'frequency'])
self.assertEqual(view.STATS["frequency"].keywords["bins"], 220)
self.assertListEqual(view.AGG_ALLOWED, [])
......@@ -2,20 +2,18 @@ from rest_framework.views import APIView
from .serializers import AggSerializer
from utils.views_commons import CommonViewsWithYear
from .apps import LandcoverConfig as Config
from utils.statistics import most_common_value, relative_frequency
class LandcoverView(APIView, CommonViewsWithYear):
def __init__(self):
opts = dict(min_valid=1,
max_valid=220,
opts = dict(default_value=0.,
out_of_bounds_value=0.,
min_valid=1.,
max_valid=220.,
serializer=AggSerializer,
service_type=Config.name)
CommonViewsWithYear.__init__(self, **opts)
self.keep_only_given_agg_allowed(dict(maxclass=most_common_value,
frequency=relative_frequency),
frequency=dict(bins=220,
missing_value=self.default_value))
self.keep_only_given_agg_allowed({})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment