Skip to content

Conversation

DhruvArvindSingh
Copy link
Contributor

@DhruvArvindSingh DhruvArvindSingh commented Nov 20, 2024

Resolves #3154 .

Description

This pull request:

  • adds slice method to array/fixed-endian-factory
  • adds the respective benchmarks and tests
  • updates README

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@DhruvArvindSingh
Copy link
Contributor Author

kindly review this PR!!

Copy link
Contributor

@stdlib-bot stdlib-bot left a comment

Choose a reason for hiding this comment

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

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Nov 20, 2024

Coverage Report

Package Statements Branches Functions Lines
array/fixed-endian-factory $\color{red}737/995$
$\color{green}+74.07\%$
$\color{red}36/45$
$\color{green}+80.00\%$
$\color{red}10/21$
$\color{green}+47.62\%$
$\color{red}737/995$
$\color{green}+74.07\%$

The above coverage report was generated for the changes in this PR.

@kgryte
Copy link
Member

kgryte commented Nov 20, 2024

/stdlib merge

@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Nov 20, 2024
@kgryte kgryte changed the title feat: add slice method to array/fixed endian factory feat: add slice method to array/fixed-endian-factory Nov 20, 2024
@kgryte
Copy link
Member

kgryte commented Nov 20, 2024

/stdlib lint-autofix

var str = arr.toString();
// returns '1,2,3'
```
#### TypedArrayFE.prototype.slice()
Copy link
Member

Choose a reason for hiding this comment

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

See https://github.com/stdlib-js/stdlib/tree/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool#booleanarrayprototypeslice-start-end- for what is excepted in terms of documentation. Additionally, this documentation should be inserted such that methods are listed in alphabetical order.

Copy link
Member

Choose a reason for hiding this comment

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

You are missing a separate benchmark file which evaluates performance as a function of array length. E.g., https://github.com/stdlib-js/stdlib/blob/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool/benchmark/benchmark.slice.length.js

* @returns {TypedArray} string representation
*/

setReadOnly( TypedArray.prototype, 'slice', function slice() {
Copy link
Member

Choose a reason for hiding this comment

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

Insert this method so that methods are listed in alphabetical order.

});

/**
* return sliced TypedArray.
Copy link
Member

Choose a reason for hiding this comment

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

Your code should look very similar to

* Copies a portion of a typed array to a new typed array.
. Currently, it does not.

* @memberof TypedArray.prototype
* @type {Function}
* @throws {TypeError} `this` must be a typed array instance
* @returns {TypedArray} string representation
Copy link
Member

Choose a reason for hiding this comment

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

The description is incorrect.

/**
* return sliced TypedArray.
*
* @private
Copy link
Member

Choose a reason for hiding this comment

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

Indentation is off.

if (value2 === null || nargs === 1) {
value2 = this._length;
}
if ( nargs < 0 || nargs > 2 || !isNonNegativeInteger( value1 ) || !isNonNegativeInteger( value2 ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Should accept negative integers, not just nonnegative integers.

if ( !isTypedArray( this ) ) {
throw new TypeError(format('invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0]], CTOR_NAME));
}
temp = [];
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this temporary array. As in

out = new this.constructor( outlen );
, you can create a new instance and then copy elements directly to the target array DataView buffer.


// TESTS //

tape('main export is a function', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

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

Please follow stdlib spacing conventions consistently throughout this file.

Copy link
Member

Choose a reason for hiding this comment

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

Your tests should essentially follow the same structure as https://github.com/stdlib-js/stdlib/blob/4b1d77d2bd001d5970ce93230765a579fb41349d/lib/node_modules/%40stdlib/array/bool/test/test.slice.js. For every set of tests in that package, I would expect to see similar tests in this package.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Nov 20, 2024
@kgryte
Copy link
Member

kgryte commented Nov 20, 2024

CI failures will need to be resolved before this PR can receive further review. Cheers!

@DhruvArvindSingh
Copy link
Contributor Author

@kgryte please review PR#3269 i have made the necessary changes told by you above

@DhruvArvindSingh DhruvArvindSingh deleted the #3154_add_slice_method_to_array/fixed-endian-factory branch December 6, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add slice method to array/fixed-endian-factory

3 participants