这是indexloc提供的服务,不要输入任何密码
Skip to content

Enable partial stacking at Batch level #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/base/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ def test_batch_cat_and_stack():
b34_stack = Batch.stack((b3, b4), axis=1)
assert np.all(b34_stack.a == np.stack((b3.a, b4.a), axis=1))
assert np.all(b34_stack.c.d == list(map(list, zip(b3.c.d, b4.c.d))))
b5_dict = np.array([{'a': False, 'b': {'c': 2.0, 'd': 1.0}},
{'a': True, 'b': {'c': 3.0}}])
b5 = Batch(b5_dict)
assert b5.a[0] == np.array(False) and b5.a[1] == np.array(True)
assert np.all(b5.b.c == np.stack([e['b']['c'] for e in b5_dict], axis=0))
assert b5.b.d[0] == b5_dict[0]['b']['d']
assert b5.b.d[1] == 0.0


def test_batch_over_batch_to_torch():
Expand Down
2 changes: 1 addition & 1 deletion test/base/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_replaybuffer(size=10, bufsize=20):
assert b.info.a[0] == 3 and b.info.a.dtype == np.integer
assert np.all(b.info.a[1:] == 0)
assert b.info.b.c[0] == 5.0 and b.info.b.c.dtype == np.inexact
assert np.all(np.isnan(b.info.b.c[1:]))
assert np.all(b.info.b.c[1:] == 0.0)


def test_ignore_obs_next(size=10):
Expand Down
Loading