Exemple #1
0
    def test_get_field_records_when_some_responses_are_empty(self):
        submissions = ['1', '2', '3', 'no_age']
        path = os.path.join(
            os.path.dirname(__file__), "fixtures", "tutorial", "tutorial.xls")
        self._publish_xls_file_and_set_xform(path)

        for i in submissions:
            self._make_submission(os.path.join(
                'onadata', 'apps', 'api', 'tests', 'fixtures', 'forms',
                'tutorial', 'instances', '{}.xml'.format(i)))

        field = 'age'
        records = get_field_records(field, self.xform)
        self.assertEqual(records, [23, 23, 35])
Exemple #2
0
    def test_get_field_records_when_some_responses_are_empty(self):
        submissions = ['1', '2', '3', 'no_age']
        path = os.path.join(
            os.path.dirname(__file__), "fixtures", "tutorial", "tutorial.xls")
        self._publish_xls_file_and_set_xform(path)

        for i in submissions:
            self._make_submission(os.path.join(
                'onadata', 'apps', 'api', 'tests', 'fixtures', 'forms',
                'tutorial', 'instances', '{}.xml'.format(i)))

        field = 'age'
        records = get_field_records(field, self.xform)
        self.assertEqual(sorted(records), sorted([23, 23, 35]))
Exemple #3
0
    def test_get_field_records_when_some_responses_are_empty(self):
        submissions = ["1", "2", "3", "no_age"]
        path = os.path.join(os.path.dirname(__file__), "fixtures", "tutorial", "tutorial.xls")
        self._publish_xls_file_and_set_xform(path)

        for i in submissions:
            self._make_submission(
                os.path.join(
                    "onadata", "apps", "api", "tests", "fixtures", "forms", "tutorial", "instances", "{}.xml".format(i)
                )
            )

        field = "age"
        records = get_field_records(field, self.xform)
        self.assertEqual(sorted(records), sorted([23, 23, 35]))
Exemple #4
0
def get_min_max_range_for_field(field, xform):
    a = np.array(get_field_records(field, xform))
    _max = np.max(a)
    _min = np.min(a)
    _range = _max - _min
    return _min, _max, _range
Exemple #5
0
def get_mode_for_field(field, xform):
    a = np.array(get_field_records(field, xform))
    m, count = mode(a)
    return m
Exemple #6
0
def get_mean_for_field(field, xform):
    return np.mean(get_field_records(field, xform))
Exemple #7
0
def get_min_max_range_for_field(field, xform):
    a = np.array(get_field_records(field, xform))
    _max = np.max(a)
    _min = np.min(a)
    _range = _max - _min
    return _min, _max, _range
Exemple #8
0
def get_mode_for_field(field, xform):
    a = np.array(get_field_records(field, xform))
    m, count = mode(a)
    return m
Exemple #9
0
def get_mean_for_field(field, xform):
    return np.mean(get_field_records(field, xform))