Skip to content

Commit

Permalink
Moved make_filename to BaseBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-kh committed Jun 14, 2017
1 parent 52e7ee6 commit dc20fe4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions dataset/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ def run_once(self, *args, **kwargs):
_ = self.data, args, kwargs
return [[]]

@staticmethod
def make_filename():
""" Generate unique filename for the batch """
random_data = np.random.uniform(0, 1, size=10) * 123456789
# probability of collision is around 2e-10.
filename = hexlify(random_data.data)[:8]
return filename.decode("utf-8")

def infer_dtype(self, data=None):
""" Detect dtype of batch data """
if data is None:
Expand Down
9 changes: 9 additions & 0 deletions dataset/batch_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Contains the base batch class """
import numpy as np
from .decorators import action


Expand All @@ -10,6 +11,14 @@ def __init__(self, index):
self.index = index
self._data = None

@staticmethod
def make_filename():
""" Generate unique filename for the batch """
random_data = np.random.uniform(0, 1, size=10) * 123456789
# probability of collision is around 2e-10.
filename = hexlify(random_data.data)[:8]
return filename.decode("utf-8")

@action
def load(self, src, fmt=None):
""" Load data from a file or another data source """
Expand Down

0 comments on commit dc20fe4

Please sign in to comment.