MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / fibonacci_numbering

Function fibonacci_numbering

test/ext/test_orderinglist.py:28–45  ·  view source on GitHub ↗

almost fibonacci- skip the first 2 steps e.g. 1, 2, 3, 5, 8, ... instead of 0, 1, 1, 2, 3, ... otherwise ordering of the elements at '1' is undefined... ;)

(order_col)

Source from the content-addressed store, hash-verified

26
27
28def fibonacci_numbering(order_col):
29 """
30 almost fibonacci- skip the first 2 steps
31 e.g. 1, 2, 3, 5, 8, ... instead of 0, 1, 1, 2, 3, ...
32 otherwise ordering of the elements at '1' is undefined... ;)
33 """
34
35 def f(index, collection):
36 if index == 0:
37 return 1
38 elif index == 1:
39 return 2
40 else:
41 return getattr(collection[index - 1], order_col) + getattr(
42 collection[index - 2], order_col
43 )
44
45 return f
46
47
48def alpha_ordering(index, collection):

Callers 1

test_funky_orderingMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected