-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RamanjaneyuluIdavalapati
committed
Jun 17, 2018
1 parent
72b3f56
commit d1822fb
Showing
6 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .command import main | ||
from .diskarray import DiskArray | ||
from .vararray import DiskVarArray | ||
from .strarray import DiskStringArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from logging import Logger | ||
|
||
import numpy as np | ||
|
||
from .vararray import DiskVarArray | ||
|
||
class DiskStringArray(DiskVarArray): | ||
# Index to word | ||
def __init__(self, dpath, mode='r+', | ||
growby=DiskVarArray.GROWBY, | ||
log=Logger): | ||
super(DiskStringArray, self).__init__(dpath, | ||
dtype=np.uint8, dtype_index=np.uint64, | ||
mode=mode, growby=growby, log=log) | ||
|
||
def __getitem__(self, idx): | ||
data = super(DiskStringArray, self).__getitem__(idx) | ||
return data.tostring() | ||
|
||
def append(self, v): | ||
v = np.array(list(v), dtype=np.uint8) | ||
return super(DiskStringArray, self).append(v) | ||
|
||
def extend(self, v): | ||
v = [np.array(list(x), dtype=np.uint8) for x in v] | ||
return super(DiskStringArray, self).extend(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters