2022.12 #133

Merged
edraft merged 85 commits from 2022.12 into master 2022-12-25 11:58:35 +01:00
4 changed files with 47 additions and 3 deletions
Showing only changes of commit 2e0a8bb1ff - Show all commits

View File

@ -3,8 +3,8 @@
"Name": "cpl-discord",
"Version": {
"Major": "2022",
"Minor": "10",
"Micro": "0.post6"
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -21,6 +21,10 @@ class SequenceABC(ABC):
self._type = t
self._set_values(values)
@classmethod
def __class_getitem__(cls, _t: type):
return _t
def __len__(self):
return len(self._values)
@ -71,6 +75,15 @@ class SequenceABC(ABC):
"""
return [x for x in self]
def copy(self) -> 'SequenceABC':
r"""Creates a copy of sequence
Returns
-------
SequenceABC
"""
return type(self)(self._type, self.to_list())
@classmethod
def empty(cls) -> 'SequenceABC':
r"""Returns an empty sequence
@ -81,6 +94,23 @@ class SequenceABC(ABC):
"""
return cls()
def index(self, _object: object) -> int:
r"""Returns the index of given element
Returns
-------
Index of object
Raises
-------
IndexError if object not in sequence
"""
for i, o in enumerate(self):
if o == _object:
return i
raise IndexError
@classmethod
def range(cls, start: int, length: int) -> 'SequenceABC':
return cls(int, list(range(start, length)))

View File

@ -56,6 +56,20 @@ class IterableABC(QueryableABC):
return self
def remove(self, _object: object):
r"""Removes element from list
Parameter
---------
_object: :class:`object`
value
"""
if _object not in self:
raise ValueError
values = [*self._values]
values.remove(_object)
self._set_values(values)
def to_enumerable(self) -> 'EnumerableABC':
r"""Converts :class: `cpl_query.iterable.iterable_abc.IterableABC` to :class: `cpl_query.enumerable.enumerable_abc.EnumerableABC`

View File

@ -342,7 +342,7 @@ class IterableQueryTestCase(unittest.TestCase):
self.assertEqual(skipped.to_list(), self._tests[:-5])
self.assertEqual(skipped.last(), self._tests[:-5][len(self._tests[:-5]) - 1])
def test_sum(self):
def test_sum(self) -> List['int']:
res = self._tests.sum(lambda u: u.address.nr)
s_res = 0