Completed
Push — master ( d1f0a7...3b2ece )
by Edward
21:04 queued 05:38
created

st2tests.resources.packs.pythonactions.actions.PascalRowAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 8
Duplicated Lines 0 %
Metric Value
wmc 3
dl 0
loc 8
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _compute_pascal_row() 0 4 2
A run() 0 2 1
1
import math
2
3
4
from st2actions.runners.pythonrunner import Action
5
6
7
class PascalRowAction(Action):
8
    def run(self, **kwargs):
9
        return PascalRowAction._compute_pascal_row(**kwargs)
10
11
    @staticmethod
12
    def _compute_pascal_row(row_index=0):
13
        return [math.factorial(row_index) / (math.factorial(i) * math.factorial(row_index - i))
14
                for i in range(row_index + 1)]
15