Skip to content

Commit

Permalink
session.annotations.put() returns indexes of added objects (#1493)
Browse files Browse the repository at this point in the history
* session.annotations.put() returns indexes of added objects

* Updated changelog
  • Loading branch information
bsekachev authored May 5, 2020
1 parent e6ce775 commit 9740ad7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-

### Changed
-
- cvat-core: session.annotations.put() now returns identificators of added objects (<https://github.com/opencv/cvat/pull/1493>)

### Deprecated
-
Expand Down
2 changes: 2 additions & 0 deletions cvat-core/src/annotations-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@
object.removed = false;
});
}, importedArray.map((object) => object.clientID), objectStates[0].frame);

return importedArray.map((value) => value.clientID);
}

select(objectStates, x, y) {
Expand Down
1 change: 1 addition & 0 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
* @method put
* @memberof Session.annotations
* @param {module:API.cvat.classes.ObjectState[]} data
* @returns {number[]} identificators of added objects
* array of objects on the specific frame
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.DataError}
Expand Down
16 changes: 12 additions & 4 deletions cvat-core/tests/api/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await task.annotations.put([state]);
const indexes = await task.annotations.put([state]);
annotations = await task.annotations.get(1);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
expect(annotations).toHaveLength(length + 1);
});

Expand All @@ -108,7 +110,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await job.annotations.put([state]);
const indexes = await job.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await job.annotations.get(5);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -128,7 +132,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await task.annotations.put([state]);
const indexes = await task.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await task.annotations.get(1);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -148,7 +154,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await job.annotations.put([state]);
const indexes = await job.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await job.annotations.get(5);
expect(annotations).toHaveLength(length + 1);
});
Expand Down

0 comments on commit 9740ad7

Please sign in to comment.