Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
4421a558
Commit
4421a558
authored
Mar 15, 2002
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'total' to 'sequence_length' and make it lazy.
parent
72f599e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
lib/python/ZTUtils/Batch.py
lib/python/ZTUtils/Batch.py
+9
-4
lib/python/ZTUtils/CHANGES.txt
lib/python/ZTUtils/CHANGES.txt
+2
-2
lib/python/ZTUtils/tests/testBatch.py
lib/python/ZTUtils/tests/testBatch.py
+3
-3
No files found.
lib/python/ZTUtils/Batch.py
View file @
4421a558
...
...
@@ -12,8 +12,8 @@
##############################################################################
__doc__
=
'''Batch class, for iterating over a sequence in batches
$Id: Batch.py,v 1.
8 2002/03/15 16:01:52 chrisw
Exp $'''
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
$Id: Batch.py,v 1.
9 2002/03/15 21:47:38 evan
Exp $'''
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
from
ExtensionClass
import
Base
...
...
@@ -31,12 +31,18 @@ class LazyNextBatch(Base):
parent
.
end
-
parent
.
overlap
,
0
,
parent
.
orphan
,
parent
.
overlap
)
class
LazySequenceLength
(
Base
):
def
__of__
(
self
,
parent
):
parent
.
sequence_length
=
l
=
len
(
parent
.
_sequence
)
return
l
class
Batch
(
Base
):
"""Create a sequence batch"""
__allow_access_to_unprotected_subobjects__
=
1
previous
=
LazyPrevBatch
()
next
=
LazyNextBatch
()
sequence_length
=
LazySequenceLength
()
def
__init__
(
self
,
sequence
,
size
,
start
=
0
,
end
=
0
,
orphan
=
0
,
overlap
=
0
):
...
...
@@ -54,7 +60,7 @@ class Batch(Base):
0-based index. "length" is the actual number of elements in
the batch.
"
total
" is the length of the original, unbatched, sequence
"
sequence_length
" is the length of the original, unbatched, sequence
'''
start
=
start
+
1
...
...
@@ -70,7 +76,6 @@ class Batch(Base):
self
.
overlap
=
overlap
self
.
first
=
max
(
start
-
1
,
0
)
self
.
length
=
self
.
end
-
self
.
first
self
.
total
=
len
(
sequence
)
if
self
.
first
==
0
:
self
.
previous
=
None
...
...
lib/python/ZTUtils/CHANGES.txt
View file @
4421a558
...
...
@@ -4,11 +4,11 @@ ZTUtils changes
Change information for previous versions can be found in the
file HISTORY.txt.
After Version 1.1.
3
After Version 1.1.
4
Features Added
- Added
useful 'total
' attribute to batches.
- Added
'sequence_length
' attribute to batches.
Version 1.1.4
...
...
lib/python/ZTUtils/tests/testBatch.py
View file @
4421a558
...
...
@@ -23,7 +23,7 @@ class BatchTests(TestCase):
assert
b
.
next
is
None
assert
b
.
start
==
1
,
b
.
start
assert
len
(
b
)
==
b
.
end
==
bsize
assert
b
.
total
==
len
(
seq
)
assert
b
.
sequence_length
==
len
(
seq
)
for
i
in
seq
:
assert
b
[
i
]
==
i
,
(
b
[
i
],
i
)
neg
=
-
1
-
i
...
...
@@ -36,10 +36,10 @@ class BatchTests(TestCase):
assert
b
.
next
is
None
assert
len
(
b
)
==
bsize
assert
b
[
bsize
-
1
]
==
bsize
-
1
assert
b
.
total
==
bsize
assert
b
.
sequence_length
==
bsize
b
=
Batch
(
range
(
8
),
5
)
assert
len
(
b
)
==
5
assert
b
.
total
==
8
assert
b
.
sequence_length
==
8
assert
len
(
b
.
next
)
==
3
def
test_suite
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment