MCPcopy Create free account
hub / github.com/Lauriat/funct / Array

Class Array

funct/Array.py:26–1262  ·  view source on GitHub ↗

A functional mutable sequence inheriting from the built-in list.

Source from the content-addressed store, hash-verified

24
25
26class Array(list):
27 """
28 A functional mutable sequence
29 inheriting from the built-in list.
30 """
31
32 __baseIterables = (list, range, tuple)
33
34 def __init__(self, *args):
35
36 """
37 Constructs an Array from arguments.
38 Nested lists, tuples and range objects are converted to
39 Arrays, while other iterables will stored as Array elements.
40 """
41 if len(args) == 1 and isinstance(args[0], Iterable):
42 args = list(args[0])
43
44 if any(map(lambda e: isinstance(e, Array.__baseIterables), args)):
45 super().__init__(self.__convert(a) for a in args)
46 else:
47 super().__init__(args)
48
49 def add(self, e, inplace=False):
50 """
51 Element-wise addition with given scalar or sequence.
52 """
53 return self.__operate(operator.add, e, inplace)
54
55 def add_(self, e):
56 """
57 Inplace element-wise addition with given scalar or sequence.
58 """
59 warn()
60 self[:] = self.__operate(operator.add, e, True)
61 return self
62
63 def sub(self, e, inplace=False):
64 """
65 Element-wise subtraction with given scalar or sequence.
66 """
67 return self.__operate(operator.sub, e, inplace)
68
69 def sub_(self, e):
70 """
71 Inplace element-wise subtraction with given scalar or sequence.
72 """
73 warn()
74 self[:] = self.__operate(operator.sub, e, True)
75 return self
76
77 def mul(self, e, inplace=False):
78 """
79 Element-wise multiplication with given scalar or sequence.
80 """
81 return self.__operate(operator.mul, e, inplace)
82
83 def mul_(self, e):

Callers 15

testMethod · 0.90
test_errsMethod · 0.90
absMethod · 0.85
floorMethod · 0.85
floor_Method · 0.85
ceilMethod · 0.85
ceil_Method · 0.85
roundMethod · 0.85
round_Method · 0.85
accumulateMethod · 0.85
clipMethod · 0.85
clip_Method · 0.85

Calls

no outgoing calls

Tested by 2

testMethod · 0.72
test_errsMethod · 0.72