Skip to content

feat: add array/base/last #1023

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 6 commits into from
May 31, 2023
Merged

feat: add array/base/last #1023

merged 6 commits into from
May 31, 2023

Conversation

Infinage
Copy link
Contributor

Description

What is the purpose of this pull request?

This pull request:

  • Adds support for returning the last element of an array-like object

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

If applied, this commit will bring in the changes to return the last
element from an array like object.

Closes: #858
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.

🎉 Welcome! 🎉

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

@Infinage Infinage mentioned this pull request May 31, 2023
3 tasks
@kgryte kgryte added Feature Issue or pull request for adding a new feature. Utilities Issue or pull request concerning general utilities. labels May 31, 2023
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @Infinage!

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @Infinage!

@kgryte kgryte merged commit 3497425 into stdlib-js:develop May 31, 2023
@kgryte kgryte changed the title feat: functionality for @stdlib/array/base/last feat: add array/base/last May 31, 2023
@Infinage Infinage deleted the feature/array-base-last branch May 31, 2023 09:08
@Infinage
Copy link
Contributor Author

Thanks for the review and the merge @kgryte! I will take better care of the edge cases and add better examples the next time. Most of the changes you did made sense. But I am just curious about these two changes:

  1. Why are we multiplying the len by 2 in the createBenchmark()?

image

  1. I am assuming this one is done for better documentation of the test results. I noticed that in the other packages we had benchmark.length.js in addition to the benchmark.js file. I wasn't able to understand the difference between those two files. However do we need to rename this file to benchmark.length.js since I see pkg+':len='+len only in files with this name?

image

@kgryte
Copy link
Member

kgryte commented May 31, 2023

@Infinage Regarding changes,

  1. You need to multiply by 2 in order for the Complex64Array to have the expected length. A complex number array has interleaved real and imaginary components. Meaning, for every complex number element, the element is comprised of a real number and a complex number which are adjacent in memory. Hence, when allocating the underlying buffer, we need to double the storage capacity.

  2. Yes, in general, for benchmarks which measuring performance as a function of array length, we use the .length.js suffix to make clear that the benchmark considers input argument size when measuring perf. We use pkg+':len='+len as the file is dynamically creating benchmark functions, and we need to be able to distinguish the benchmark runs from one another in the TAP output.

For now, you do not need to rename the file. I can take care of that on my end.

Hope this answers your questions.

@Infinage
Copy link
Contributor Author

Infinage commented Jun 1, 2023

Yes it does, thanks!

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. Utilities Issue or pull request concerning general utilities.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Add @stdlib/array/base/last
3 participants