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

Fix Batch to numpy compatibility #92

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 12 commits into from
Jun 24, 2020
Merged

Conversation

duburcqa
Copy link
Collaborator

@duburcqa duburcqa commented Jun 24, 2020

  • Modify Batch class to behave similarly to numpy, especially regarding slicing and get length
  • Batch can now be initialized with a wide variety of argument types, making it very user friendly and intuitive
  • Add numpy compatibility with Batch. It is now possible to do something like np.mean(Batch(...)) and get the expected result. Incidently, it is also possible to do list(Batch(...)) to split a Batch, or loop over samples doing for sample in Batch(...): ...
  • Add size method and modify __len__ to behave similarly to numpy

Related to issue #90

@Trinkle23897 Trinkle23897 linked an issue Jun 24, 2020 that may be closed by this pull request
@duburcqa duburcqa force-pushed the batch_to_numpy branch 5 times, most recently from e5e1772 to 1496e7f Compare June 24, 2020 10:39
@duburcqa duburcqa force-pushed the batch_to_numpy branch 7 times, most recently from 3c41837 to ba83e42 Compare June 24, 2020 12:11
@duburcqa duburcqa changed the title WIP: Fix Batch to numpy compatibility Fix Batch to numpy compatibility Jun 24, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2020

Codecov Report

Merging #92 into master will decrease coverage by 0.55%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
- Coverage   85.36%   84.80%   -0.56%     
==========================================
  Files          29       29              
  Lines        1783     1843      +60     
==========================================
+ Hits         1522     1563      +41     
- Misses        261      280      +19     
Flag Coverage Δ
#unittests 84.80% <75.00%> (-0.56%) ⬇️
Impacted Files Coverage Δ
tianshou/data/batch.py 86.84% <73.33%> (-6.58%) ⬇️
tianshou/data/buffer.py 96.84% <100.00%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebc551a...96e2751. Read the comment docs.

@Trinkle23897 Trinkle23897 merged commit 49f43e9 into thu-ml:master Jun 24, 2020
@duburcqa duburcqa deleted the batch_to_numpy branch June 25, 2020 12:47
BFAnas pushed a commit to BFAnas/tianshou that referenced this pull request May 5, 2024
* Fix Batch to numpy compatibility.

* Fix Batch unit tests.

* Fix linter

* Add Batch shape method.

* Remove shape and add size. Enable to reserve keys using empty batch/list.

* Fix linter and unit tests.

* Batch init using list of Batch.

* Add unit tests.

* Fix Batch __len__.

* Fix unit tests.

* Fix slicing

* Add missing slicing unit tests.

Co-authored-by: Alexis Duburcq <alexis.duburcq@wandercraft.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch to Numpy compatibility
3 participants