Skip to content

Test fails - division by zero #2

Open
@tomron

Description

@tomron

I run the test as described in the read me and I get the following error -

======================================================================
ERROR: test_cronbach_alphas (test.StatsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/tomron/code/processRat/tci-stats/test/__init__.py", line 9, in test_cronbach_alphas
    self.assertEqual(cronbach_alpha(data), 1)
  File "/Users/tomron/code/processRat/tci-stats/tcistats/__init__.py", line 11, in cronbach_alpha
    (1 - variance_sum / total_var))
ZeroDivisionError: float division by zero
----------------------------------------------------------------------

It has to do with total_variance=0. So the solution might be -

if total_variance == 0:
    return 1
return ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions