Skip to content
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

Implements set_env_attr and get_env_attr for vector environments #478

Merged
merged 5 commits into from
Nov 2, 2021
Merged
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions test/throughput/test_batch_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@pytest.fixture(scope="module")
def data():
print("Initialising data...")
print("Initializing data...")
np.random.seed(0)
batch_set = [
Batch(
Expand All @@ -19,16 +19,16 @@ def data():
'b1': (3.14, 3.14),
'b2': np.arange(1e3)
},
c=i
c=i,
) for i in np.arange(int(1e4))
]
batch0 = Batch(
a=np.ones((3, 4), dtype=np.float64),
b=Batch(
c=np.ones((1, ), dtype=np.float64),
d=torch.ones((3, 3, 3), dtype=torch.float32),
e=list(range(3))
)
e=list(range(3)),
),
)
batchs1 = [copy.deepcopy(batch0) for _ in np.arange(1e4)]
batchs2 = [copy.deepcopy(batch0) for _ in np.arange(1e4)]
Expand All @@ -39,25 +39,25 @@ def data():
indexs = np.random.choice(batch_len, size=batch_len // 10, replace=False)
slice_dict = {
'obs': [np.arange(20) for _ in np.arange(batch_len // 10)],
'reward': np.arange(batch_len // 10)
'reward': np.arange(batch_len // 10),
}
dict_set = [
{
'obs': np.arange(20),
'info': "this is info",
'reward': 0
'reward': 0,
} for _ in np.arange(1e2)
]
batch4 = Batch(
a=np.ones((10000, 4), dtype=np.float64),
b=Batch(
c=np.ones((1, ), dtype=np.float64),
d=torch.ones((1000, 1000), dtype=torch.float32),
e=np.arange(1000)
)
e=np.arange(1000),
),
)

print("Initialised")
print("Initialized")
return {
'batch_set': batch_set,
'batch0': batch0,
Expand All @@ -67,7 +67,7 @@ def data():
'indexs': indexs,
'dict_set': dict_set,
'slice_dict': slice_dict,
'batch4': batch4
'batch4': batch4,
}


Expand Down Expand Up @@ -106,7 +106,7 @@ def test_set_attr(data):

def test_numpy_torch_convert(data):
"""Test conversion between numpy and torch."""
for _ in np.arange(1e5):
for _ in np.arange(1e4): # not sure what's wrong in torch==1.10.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

data['batch4'].to_torch()
data['batch4'].to_numpy()

Expand Down