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

Empty extend fix #1335

Closed
wants to merge 4 commits into from
Closed

Empty extend fix #1335

wants to merge 4 commits into from

Conversation

farizrahman4u
Copy link
Contributor

🚀 🚀 Pull Request

Checklist:

  • My code follows the style guidelines of this project and the Contributing document
  • I have commented my code, particularly in hard-to-understand areas
  • I have kept the coverage-rate up
  • I have performed a self-review of my own code and resolved any problems
  • I have checked to ensure there aren't any other open Pull Requests for the same change
  • I have described and made corresponding changes to the relevant documentation
  • New and existing unit tests pass locally with my changes

Changes

Fixes dataset corruption when extending with empty list / array

https://activeloop.atlassian.net/browse/AL-1418

@CLAassistant
Copy link

CLAassistant commented Nov 9, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #1335 (73d2d6c) into main (fcc922f) will decrease coverage by 0.94%.
The diff coverage is 100.00%.

❗ Current head 73d2d6c differs from pull request most recent head 44e3523. Consider uploading reports for the commit 44e3523 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1335      +/-   ##
==========================================
- Coverage   91.80%   90.85%   -0.95%     
==========================================
  Files         151      146       -5     
  Lines       10820    10484     -336     
==========================================
- Hits         9933     9525     -408     
- Misses        887      959      +72     
Flag Coverage Δ
unittests 90.85% <100.00%> (-0.95%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
hub/api/tests/test_api.py 99.42% <100.00%> (+<0.01%) ⬆️
hub/core/chunk_engine.py 87.89% <100.00%> (-7.72%) ⬇️
hub/integrations/pytorch/common.py 61.53% <0.00%> (-36.29%) ⬇️
hub/core/lock.py 82.22% <0.00%> (-8.89%) ⬇️
hub/core/dataset/hub_cloud_dataset.py 86.88% <0.00%> (-4.79%) ⬇️
hub/core/serialize.py 94.32% <0.00%> (-4.26%) ⬇️
hub/integrations/pytorch/pytorch.py 84.00% <0.00%> (-2.21%) ⬇️
hub/core/transform/test_transform.py 93.40% <0.00%> (-1.85%) ⬇️
hub/util/version_control.py 97.22% <0.00%> (-1.67%) ⬇️
... and 30 more

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 42f328c...44e3523. Read the comment docs.

Copy link
Contributor

@jraman jraman left a comment

Choose a reason for hiding this comment

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

lgtm, but for minor test change.

@@ -794,3 +794,13 @@ def test_tobytes(memory_ds, compressed_image_paths, audio_paths):
for i in range(3):
assert ds.image[i].tobytes() == image_bytes
assert ds.audio[i].tobytes() == audio_bytes


def test_empty_extend(memory_ds):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a doc line like "test extend empty tensor" or rename the test to something like test_extend_empty_tensor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not testing extending an empty tensor, but rather extending a tensor with an empty list/array.

ds.x.append(1)
ds.create_tensor("y")
ds.y.extend(np.zeros((len(ds), 3)))
assert len(ds) == 0
Copy link
Contributor

@jraman jraman Nov 9, 2021

Choose a reason for hiding this comment

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

What is the expected len(ds.y) here? Please add assertion.

@farizrahman4u
Copy link
Contributor Author

Moved to #1365

@AbhinavTuli AbhinavTuli deleted the fr_extend_bug_fix branch December 28, 2021 13:35
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.

3 participants