def test_io_datagenerator_x_batches(): X = numpy.random.randn(500, 13) w = numpy.ones(500) data = DataGenerator(X) X_ = numpy.concatenate([batch[0] for batch in data.batches()]) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(X, X_) assert_almost_equal(w, w_) data = DataGenerator(X, batch_size=123) X_ = numpy.concatenate([batch[0] for batch in data.batches()]) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(X, X_) assert_almost_equal(w, w_) data = DataGenerator(X, batch_size=1) X_ = numpy.concatenate([batch[0] for batch in data.batches()]) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(X, X_) assert_almost_equal(w, w_) data = DataGenerator(X, batch_size=506) X_ = numpy.concatenate([batch[0] for batch in data.batches()]) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(X, X_) assert_almost_equal(w, w_)
def test_io_datagenerator_wy_batches(): X = numpy.random.randn(500, 13) w = numpy.abs(numpy.random.randn(500)) y = numpy.random.randint(5, size=500) data = DataGenerator(X, w, y) y_ = numpy.concatenate([batch[1] for batch in data.batches()]) w_ = numpy.concatenate([batch[2] for batch in data.batches()]) assert_almost_equal(y, y_) assert_almost_equal(w, w_) data = DataGenerator(X, w, y, batch_size=123) y_ = numpy.concatenate([batch[1] for batch in data.batches()]) w_ = numpy.concatenate([batch[2] for batch in data.batches()]) assert_almost_equal(y, y_) assert_almost_equal(w, w_) data = DataGenerator(X, w, y, batch_size=1) y_ = numpy.concatenate([batch[1] for batch in data.batches()]) w_ = numpy.concatenate([batch[2] for batch in data.batches()]) assert_almost_equal(y, y_) assert_almost_equal(w, w_) data = DataGenerator(X, w, y, batch_size=506) y_ = numpy.concatenate([batch[1] for batch in data.batches()]) w_ = numpy.concatenate([batch[2] for batch in data.batches()]) assert_almost_equal(y, y_) assert_almost_equal(w, w_)
def test_io_datagenerator_w_batches(): X = numpy.random.randn(500, 13) w = numpy.abs(numpy.random.randn(500)) data = DataGenerator(X, w) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(w, w_) data = DataGenerator(X, w, batch_size=123) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(w, w_) data = DataGenerator(X, w, batch_size=1) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(w, w_) data = DataGenerator(X, w, batch_size=506) w_ = numpy.concatenate([batch[1] for batch in data.batches()]) assert_almost_equal(w, w_)