Skip to content

feat: add array/float16 #7435

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

udaykakade25
Copy link
Contributor

progresses #7347 and #7273

Description

What is the purpose of this pull request?

This pull request:

  • Adds array/float16 folder

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.

This is the third PR. First two PRs are interconnected to each other. In order to merge this PR, we need to first merge PR 1: #7273 and #7347

Checklist

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


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jun 21, 2025
@udaykakade25
Copy link
Contributor Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jun 21, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jun 21, 2025
@udaykakade25
Copy link
Contributor Author

Hello @Planeshifter and @kgryte sir,
With this PR, i have completed array/float16.
Please do review and merge PR along with two previously mentioned PRs.

So, i can start working on adding float16 datatype support for array/base, array/*, strided/8 and ndarray/*


// MAIN //

class Float16Array {
Copy link
Member

Choose a reason for hiding this comment

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

This entire implementation should be refactored. We do not use ES6+. All code must be written in ES5. Furthermore, all methods and properties should be documented. See array/bool and array/complex128 for what we expect.

return Float16Array.fromFloat16(this._buffer[index]);
}

get buffer() {
Copy link
Member

Choose a reason for hiding this comment

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

This file also does not conform to our style conventions and includes mixed tabs and spaces. Please follow our development guide and ensure that your local environment is properly setup. Our automated linting and EditorConfig configuration would have flagged all these issues.

const offset = value !== undefined ? Number(value) : 0;

if (offset < 0 || offset > this.length) {
throw new RangeError('Offset is out of bounds');
Copy link
Member

Choose a reason for hiding this comment

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

This is not how we format error messages.

(ArrayBuffer.isView(source) && typeof source.length === 'number') ||
(source instanceof Float16Array))
) {
const len = Math.min(source.length, this.length - offset);
Copy link
Member

Choose a reason for hiding this comment

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

We do not use Math built-ins. Everything should be implemented in terms of stdlib functionality.

return this._entriesGenerator();
}

*_entriesGenerator() {
Copy link
Member

Choose a reason for hiding this comment

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

entries should be implemented using iterators directly. Use of generators is not allowed in ES5.

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.

@udaykakade25 Thank you for working on this. I left a few initial comments. The TL;DR is that the entire implementation needs to be reworked to be implemented in ES5. I strongly encourage you to emulate the style and approach used in array/bool and other custom array types implemented in stdlib.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jun 21, 2025
@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Changes Pull request which needs changes before being merged. Potential Duplicate There might be another pull request resolving the same issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants