From 6dce21bf33132bab1dfc9d80dc3e17647923f43e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 26 Mar 2023 09:49:19 +0000 Subject: [PATCH 01/89] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..238110c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null67', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; diff --git a/package.json b/package.json index fa5fabc..f4db476 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From ec620f726d7942969d576eeb93accf7cb27376a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 26 Mar 2023 10:01:21 +0000 Subject: [PATCH 02/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 910 --- 48 files changed, 6204 insertions(+), 6088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 739bb2c..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6fcf238..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -186,7 +179,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -246,9 +239,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 7defc35..66ef2b6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1bc8fd4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..96bc48e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8+BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 238110c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null67', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index f4db476..5d48117 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "github:stdlib-js/array-empty#main", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/buffer-alloc-unsafe": "^0.0.7", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-base-zeros": "^0.0.1", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-zeros": "^0.0.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2d1c403 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From ca283ec84429b0e642286fe4df9aed0c6355e375 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:14:20 +0000 Subject: [PATCH 03/89] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..238110c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null67', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; diff --git a/package.json b/package.json index e1d61c5..caae85e 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From b9797aaae59dcd567cb65819de0131f4dfb9e34e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:15:03 +0000 Subject: [PATCH 04/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 66ef2b6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1bc8fd4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 96bc48e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8+BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2d1c403..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f9313e4290c28d0606db51dda394abbedcf6f1d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:16:03 +0000 Subject: [PATCH 05/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 910 --- 48 files changed, 6204 insertions(+), 6088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 739bb2c..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6fcf238..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -186,7 +179,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -246,9 +239,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 7defc35..66ef2b6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1bc8fd4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..96bc48e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8+BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 238110c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null67', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index caae85e..5bf690f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.0.1", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/buffer-alloc-unsafe": "^0.0.7", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-base-zeros": "^0.0.1", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-zeros": "^0.0.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..90a15fd --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From e570b21cca507c45fc67cfa8d9a9a3081195c722 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:16:48 +0000 Subject: [PATCH 06/89] Update README.md for ESM bundle v0.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73c1d9a..75c1fe8 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.1-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -128,7 +128,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.1-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 87260b3a816d24a92a7b2162b94140f5d7d40bcb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:16:49 +0000 Subject: [PATCH 07/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c1fe8..a439248 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.1-esm/index.mjs'; ``` @@ -128,7 +133,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.1-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 588c93ca9e4882a1aa16d885b4c3ed6a3f81f9cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:24:49 +0000 Subject: [PATCH 08/89] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..238110c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null67', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2h', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; diff --git a/package.json b/package.json index a856559..9cd336c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.0.8", "@stdlib/ndarray-base-strides2offset": "^0.0.8", "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From de6451d0ef595fb1c7d551d0b8237db37dd2f8d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:25:20 +0000 Subject: [PATCH 09/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 66ef2b6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1bc8fd4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 96bc48e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;8+BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 90a15fd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 01e84662714847e5e01081bd462ad07ddc49762d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:26:10 +0000 Subject: [PATCH 10/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 910 --- 48 files changed, 6204 insertions(+), 6088 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 739bb2c..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6fcf238..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -186,7 +179,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -246,9 +239,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 7defc35..66ef2b6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 2.0 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c680cd0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.0.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3546a61 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;q/BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 238110c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null67', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'null2h', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 9cd336c..d976844 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.0.1", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/buffer-alloc-unsafe": "^0.0.7", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-ctor": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/ndarray-base-zeros": "^0.0.1", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-zeros": "^0.0.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ec3ac05 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 64de40b31a30311f25810c3c09d9567ad7953876 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:26:46 +0000 Subject: [PATCH 11/89] Update README.md for ESM bundle v0.0.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcf3c47..04fa2ac 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.2-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -128,7 +128,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.2-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 1e4cc06beae8d469137da0ddbe2853f107227f1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:26:46 +0000 Subject: [PATCH 12/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04fa2ac..bcc58c8 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.2-esm/index.mjs'; ``` @@ -128,7 +133,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.0.2-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 9cbe3d26fdb12a9f41f61703b51a9f20da39a158 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:26:18 +0000 Subject: [PATCH 13/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..e9787b4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -99,7 +99,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = x.shape; diff --git a/package.json b/package.json index 39968f8..458fb84 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.1.0", "@stdlib/ndarray-base-strides2offset": "^0.1.0", "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 9f7d9d0c97deccf865de171f91c50ef4ab031e60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:58:23 +0000 Subject: [PATCH 14/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 66ef2b6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c680cd0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.0.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function l(l){var h,j,f,b,g,y,v,c;if(!e(l))throw new TypeError(a("null67",l));if(b={},arguments.length>1){if(!s(h=arguments[1]))throw new TypeError(a("null2h",h));if(j=t(h,"dtype")?h.dtype:l.dtype,t(h,"shape")){if("number"==typeof(c=h.shape)&&(c=[c]),!r(c))throw new TypeError(a("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",c))}else c=l.shape;f=t(h,"order")?h.order:l.order,t(h,"mode")&&(b.mode=h.mode),t(h,"submode")&&(b.submode=h.submode)}else j=l.dtype,c=l.shape,f=l.order;return c.length>0?((y=d(c))<0&&(y=0),v=n(c,f)):(y=1,v=[0]),g="binary"===j?p(y):m(y,j),new o(j,g,c,v,i(c,v),f,b)}export{l as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3546a61..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null67', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'null2h', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;q/BAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,SAAUX,IAGxC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,SAAUV,IAOxC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ec3ac05..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 23602e9a6549e11b865d4cdecc15c4968963a343 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:59:13 +0000 Subject: [PATCH 15/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 910 --- 52 files changed, 6204 insertions(+), 6123 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 739bb2c..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6fcf238..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 646bd53..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var f=l(function(A,m){ -var y=require('@stdlib/assert-is-ndarray-like/dist'),g=require('@stdlib/assert-is-plain-object/dist'),h=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),w=require('@stdlib/ndarray-base-numel/dist'),c=require('@stdlib/ndarray-ctor/dist'),O=require('@stdlib/array-empty/dist'),j=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function k(a){var e,i,s,d,o,v,t,u,r;if(!y(a))throw new TypeError(p('1dZ5t',a));if(o={},arguments.length>1){if(e=arguments[1],!g(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=a.dtype,n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!h(r))throw new TypeError(p('1dZDs',"shape",r))}else r=a.shape;n(e,"order")?s=e.order:s=a.order,n(e,"mode")&&(o.mode=e.mode),n(e,"submode")&&(o.submode=e.submode)}else i=a.dtype,r=a.shape,s=a.order;return d=r.length,d>0?(t=w(r),t<0&&(t=0),u=b(r,s)):(t=1,u=[0]),i==="binary"?v=j(t):v=O(t,i),new c(i,v,r,u,q(r,u),s,o)}m.exports=k -});var E=f();module.exports=E; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index db67112..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACrB,EAAeY,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACZ,EAAeY,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKV,EAAYU,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQF,EAAE,MAENT,EAAYU,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACnB,EAA2BmB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKT,EAAE,MAEHT,EAAYU,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQH,EAAE,MAENT,EAAYU,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBV,EAAYU,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQF,EAAE,MACVS,EAAKT,EAAE,MACPG,EAAQH,EAAE,MAEX,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMb,EAAOe,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKhB,EAAeiB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIf,EAAgBgB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAlB,EAAO,QAAUY,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0867e12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..815676a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e9787b4..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 458fb84..16d65eb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0e1d55f --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From bb2e356d72815f7481b9697bf746d6b239d58c4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:12:08 +0000 Subject: [PATCH 16/89] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80318d8..4870b5a 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.1.0-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -139,7 +139,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.1.0-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From ce7ab4c61b2a925986110781e69fa464ed8463fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:12:08 +0000 Subject: [PATCH 17/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4870b5a..d9e4e05 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.1.0-esm/index.mjs'; ``` @@ -139,7 +144,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.1.0-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From b97a2f000b7a85d56e648c3eb226029d91614213 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 17:10:38 +0000 Subject: [PATCH 18/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..e9787b4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -99,7 +99,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = x.shape; diff --git a/package.json b/package.json index 39968f8..458fb84 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.1.0", "@stdlib/ndarray-base-strides2offset": "^0.1.0", "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 5d9b87039cf5a9e9794032da83211a05cc1fafbb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:33:46 +0000 Subject: [PATCH 19/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0867e12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 815676a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0e1d55f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 162ab331210b82f0e549a8fe57132eac27dbcbd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:35:12 +0000 Subject: [PATCH 20/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 910 --- test/test.js | 910 --- 54 files changed, 6204 insertions(+), 7092 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5a5e63c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:33:44.670Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 646bd53..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var f=l(function(A,m){ -var y=require('@stdlib/assert-is-ndarray-like/dist'),g=require('@stdlib/assert-is-plain-object/dist'),h=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),w=require('@stdlib/ndarray-base-numel/dist'),c=require('@stdlib/ndarray-ctor/dist'),O=require('@stdlib/array-empty/dist'),j=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function k(a){var e,i,s,d,o,v,t,u,r;if(!y(a))throw new TypeError(p('1dZ5t',a));if(o={},arguments.length>1){if(e=arguments[1],!g(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=a.dtype,n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!h(r))throw new TypeError(p('1dZDs',"shape",r))}else r=a.shape;n(e,"order")?s=e.order:s=a.order,n(e,"mode")&&(o.mode=e.mode),n(e,"submode")&&(o.submode=e.submode)}else i=a.dtype,r=a.shape,s=a.order;return d=r.length,d>0?(t=w(r),t<0&&(t=0),u=b(r,s)):(t=1,u=[0]),i==="binary"?v=j(t):v=O(t,i),new c(i,v,r,u,q(r,u),s,o)}m.exports=k -});var E=f();module.exports=E; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index db67112..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACrB,EAAeY,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACZ,EAAeY,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKV,EAAYU,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQF,EAAE,MAENT,EAAYU,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACnB,EAA2BmB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKT,EAAE,MAEHT,EAAYU,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQH,EAAE,MAENT,EAAYU,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBV,EAAYU,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQF,EAAE,MACVS,EAAKT,EAAE,MACPG,EAAQH,EAAE,MAEX,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMb,EAAOe,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKhB,EAAeiB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIf,EAAgBgB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAlB,EAAO,QAAUY,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0867e12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..815676a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e9787b4..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 458fb84..16d65eb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8eb2fab --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index ffbfe24..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 80a5951f888e67a981365b8b203ee92d5d95e3d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:19:30 +0000 Subject: [PATCH 21/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index faf6b0b..e9787b4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var numel = require( '@stdlib/ndarray-base-numel' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -80,13 +80,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -99,7 +99,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = x.shape; diff --git a/package.json b/package.json index b691a4f..a595b12 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.1.1", "@stdlib/ndarray-base-strides2offset": "^0.1.1", "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 1399510b0b259fbe1a9ee1e11cb67d5bb4444b93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:37:50 +0000 Subject: [PATCH 22/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0867e12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 815676a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8eb2fab..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf5f07675808dba439083ac46f47e898ffd872be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:39:09 +0000 Subject: [PATCH 23/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 79 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 910 --- test/test.js | 910 --- 53 files changed, 6204 insertions(+), 7091 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 646bd53..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var f=l(function(A,m){ -var y=require('@stdlib/assert-is-ndarray-like/dist'),g=require('@stdlib/assert-is-plain-object/dist'),h=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),w=require('@stdlib/ndarray-base-numel/dist'),c=require('@stdlib/ndarray-ctor/dist'),O=require('@stdlib/array-empty/dist'),j=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function k(a){var e,i,s,d,o,v,t,u,r;if(!y(a))throw new TypeError(p('1dZ5t',a));if(o={},arguments.length>1){if(e=arguments[1],!g(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=a.dtype,n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!h(r))throw new TypeError(p('1dZDs',"shape",r))}else r=a.shape;n(e,"order")?s=e.order:s=a.order,n(e,"mode")&&(o.mode=e.mode),n(e,"submode")&&(o.submode=e.submode)}else i=a.dtype,r=a.shape,s=a.order;return d=r.length,d>0?(t=w(r),t<0&&(t=0),u=b(r,s)):(t=1,u=[0]),i==="binary"?v=j(t):v=O(t,i),new c(i,v,r,u,q(r,u),s,o)}m.exports=k -});var E=f();module.exports=E; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index db67112..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACrB,EAAeY,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACZ,EAAeY,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKV,EAAYU,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQF,EAAE,MAENT,EAAYU,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACnB,EAA2BmB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKT,EAAE,MAEHT,EAAYU,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQH,EAAE,MAENT,EAAYU,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBV,EAAYU,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQF,EAAE,MACVS,EAAKT,EAAE,MACPG,EAAQH,EAAE,MAEX,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMb,EAAOe,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKhB,EAAeiB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIf,EAAgBgB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAlB,EAAO,QAAUY,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f585443 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..815676a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e9787b4..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = x.dtype; - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = x.shape; - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = x.order; - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = x.dtype; - sh = x.shape; - order = x.order; - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index a595b12..16d65eb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,58 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1bf2f77 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index ffbfe24..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 6a2e80977961dd59bc7c4ccda84dbf655324daf3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 06:13:29 +0000 Subject: [PATCH 24/89] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index add0478..b8c0a21 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "github:stdlib-js/ndarray-dtype#main", "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From a5d9f993339aa0400bf182c1f696664fd67467f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 07:21:36 +0000 Subject: [PATCH 25/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f585443..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function h(h){var j,l,f,v,b,y,g,c;if(!e(h))throw new TypeError(a("1dZ5t,Kg",h));if(v={},arguments.length>1){if(!s(j=arguments[1]))throw new TypeError(a("1dZ2V,FD",j));if(l=t(j,"dtype")?j.dtype:h.dtype,t(j,"shape")){if("number"==typeof(c=j.shape)&&(c=[c]),!r(c))throw new TypeError(a("1dZKh","shape",c))}else c=h.shape;f=t(j,"order")?j.order:h.order,t(j,"mode")&&(v.mode=j.mode),t(j,"submode")&&(v.submode=j.submode)}else l=h.dtype,c=h.shape,f=h.order;return c.length>0?((y=n(c))<0&&(y=0),g=d(c,f)):(y=1,g=[0]),b="binary"===l?p(y):o(y,l),new m(l,b,c,g,i(c,g),f,v)}export{h as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 815676a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","shape","isNonNegativeIntegerArray","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;6iCAsEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERF,EAAEE,MAENa,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQe,SAEZR,EAAK,CAAEA,KAEFS,EAA2BT,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKR,EAAEgB,MAGPb,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERH,EAAEG,MAENY,EAAYd,EAAS,UACzBG,EAAKc,KAAOjB,EAAQiB,MAEhBH,EAAYd,EAAS,aACzBG,EAAKe,QAAUlB,EAAQkB,QAE1B,MACEjB,EAAQF,EAAEE,MACVM,EAAKR,EAAEgB,MACPb,EAAQH,EAAEG,MAmBX,OAjBQK,EAAGK,OACE,IACZP,EAAMc,EAAOZ,IACF,IACVF,EAAM,GAEPC,EAAKc,EAAeb,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEoB,EAAahB,GAEbiB,EAAYjB,EAAKJ,GAEjB,IAAIsB,EAAStB,EAAOG,EAAKG,EAAID,EAAIkB,EAAgBjB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1bf2f77..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4a1d365f2d37b6a225f3cbe72343770830a35dd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 07:22:36 +0000 Subject: [PATCH 26/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 149 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 910 --- test/test.js | 910 --- 53 files changed, 6204 insertions(+), 7097 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index eea0435..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,s=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,n,m,o,v,t,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(o={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(s(e,"dtype")?i=e.dtype:i=d(a),s(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);s(e,"order")?n=e.order:n=l(a),s(e,"mode")&&(o.mode=e.mode),s(e,"submode")&&(o.submode=e.submode)}else i=d(a),r=f(a),n=l(a);return m=r.length,m>0?(t=T(r),t<0&&(t=0),u=c(r,n)):(t=1,u=[0]),i==="binary"?v=E(t):v=k(t,i),new j(i,v,r,u,O(r,u),n,o)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 94c8f79..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICxGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f3f7643 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?((u=d(w))<0&&(u=0),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e166f5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;uxCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAmBnB,OAjBQQ,EAAGK,OACE,IACZP,EAAMiB,EAAOf,IACF,IACVF,EAAM,GAEPC,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 1f68545..0000000 --- a/lib/main.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - if ( len < 0 ) { - len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes) - } - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index b8c0a21..16d65eb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "github:stdlib-js/ndarray-dtype#main", - "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", - "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7dfc92e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index ffbfe24..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 90390bdd03daddd17ff1cf37c06f93655901e92c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:52:20 +0000 Subject: [PATCH 27/89] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index add0478..b8c0a21 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "github:stdlib-js/ndarray-dtype#main", "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From dbe35fb7608f39b65a380d812e1f6e2ea8b522a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:53:48 +0000 Subject: [PATCH 28/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f3f7643..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?((u=d(w))<0&&(u=0),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e166f5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;uxCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAmBnB,OAjBQQ,EAAGK,OACE,IACZP,EAAMiB,EAAOf,IACF,IACVF,EAAM,GAEPC,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7dfc92e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 73a6fcbac9dd48984ed5f2414ee0a9bd6c0a1100 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:54:59 +0000 Subject: [PATCH 29/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 53 files changed, 6204 insertions(+), 6217 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5bc2057 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ba193e0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;uxCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6057e2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index b8c0a21..16d65eb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "github:stdlib-js/ndarray-dtype#main", - "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", - "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6e85e3a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From ab1dbb4ba3a85f9fff633d6a15a4b448af9ffb04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 18:03:02 +0000 Subject: [PATCH 30/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..07ce428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 190008e..cd5123b 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 2bc7ee5e061b9deddc00fad786d6925f2f1467f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:45:18 +0000 Subject: [PATCH 31/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5bc2057..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ba193e0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;uxCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6e85e3a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fdf477a76b2ff03c44d097fd28e8ad30c744d96a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:46:25 +0000 Subject: [PATCH 32/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 54 files changed, 6204 insertions(+), 6226 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2c99fe1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:54:55.820Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +190,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -257,9 +250,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3f934a8..1537a29 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aad5fd5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..df26a0b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 07ce428..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index cd5123b..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8d7c441 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 9bdb4892d3fbcbbc4a29afe94562c63204858805 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:24:57 +0000 Subject: [PATCH 33/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..07ce428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 501a235..232c4d7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 6c442dee9979e003198ec7631159d2679014782a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:16:11 +0000 Subject: [PATCH 34/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 1537a29..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aad5fd5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index df26a0b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8d7c441..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e43adfc263c0bcafdc80abb42a2f6558cb99494c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:17:20 +0000 Subject: [PATCH 35/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 53 files changed, 6206 insertions(+), 6227 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -264,15 +257,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 6f4cfbe..61490c6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aad5fd5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..df26a0b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 07ce428..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 232c4d7..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..aefd7a2 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From e664615851ab31d986750c432baa95a035714683 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 22:23:50 +0000 Subject: [PATCH 36/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..07ce428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 501a235..232c4d7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 251b30c611e639409a47b6a743a1b5265db5582c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 23:47:30 +0000 Subject: [PATCH 37/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61490c6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -// tslint:disable:max-file-line-count - -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aad5fd5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index df26a0b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index aefd7a2..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d2744cad26a0091d6e32558f895744033f9590d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 23:48:29 +0000 Subject: [PATCH 38/89] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 79 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 53 files changed, 6206 insertions(+), 6227 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -264,15 +257,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a33a12d..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,79 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions to - either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'wrap', an ndarray instance wraps around subscripts exceeding - array dimensions using modulo arithmetic. If equal to 'clamp', an - ndarray instance sets a subscript exceeding array dimensions to either - `0` (minimum index) or the maximum index. If the number of modes is - fewer than the number of dimensions, the function recycles modes using - modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 8c939a4..980cfc4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aad5fd5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..df26a0b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 07ce428..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 232c4d7..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8ade63a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 29fccc4ed2c94e01135acec6765c62c749e8102d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:29:28 +0000 Subject: [PATCH 39/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..07ce428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 0d7253a..3e2654d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 919d0574d6184a673a1b2a942b5e18422332d5ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:32:58 +0000 Subject: [PATCH 40/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 980cfc4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aad5fd5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index df26a0b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8ade63a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e1c7ad2399fd1f37efb6757f415b9ee3ed8f32d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 Nov 2023 07:33:59 +0000 Subject: [PATCH 41/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 53 files changed, 6206 insertions(+), 6226 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -264,15 +257,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 8c939a4..980cfc4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aad5fd5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..df26a0b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 07ce428..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 3e2654d..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..be5fc35 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 48185d341bbe9ff7d7be3602dcc052160a00c62e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:12:06 +0000 Subject: [PATCH 42/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..07ce428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t,Kg', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V,FD', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZKh', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 0d7253a..3e2654d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 30f69fc348f59377e27601bd143b89eb2e9c2f84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:27:26 +0000 Subject: [PATCH 43/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 980cfc4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aad5fd5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index df26a0b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index be5fc35..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2d353563e7536332826cfd84b0073764c7a0df9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:28:13 +0000 Subject: [PATCH 44/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 54 files changed, 6206 insertions(+), 6227 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2ef0d15..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T06:00:12.852Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 109d0f1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -264,15 +257,15 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4d0bf15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index c7d51fe..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index d770d53..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index 59913db..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index 67d7f1c..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index 5d0e6af..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index 40a15b9..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index cda2a96..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index c76a5b5..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f046140..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index b1a51b3..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 16dcfdd..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index fd0db4b..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 8c939a4..980cfc4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aad5fd5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..df26a0b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 07ce428..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t,Kg', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V,FD', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZKh', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 3e2654d..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a9b17f8 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From bf3b012a28f9696db727e45a2052f66e6cbc25f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:31:36 +0000 Subject: [PATCH 45/89] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a50c94f..041cde3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From d70574c3b1d9f21e5766bf2cd575421d5b1f000e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:10:14 +0000 Subject: [PATCH 46/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 980cfc4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aad5fd5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function v(v){var f,b,g,y,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t,Kg",v));if(y={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V,FD",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZKh","shape",w))}else w=o(v);g=t(f,"order")?f.order:p(v),t(f,"mode")&&(y.mode=f.mode),t(f,"submode")&&(y.submode=f.submode)}else b=m(v),w=o(v),g=p(v);return w.length>0?(x=n(w),u=d(w,g)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index df26a0b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t,Kg', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V,FD', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZKh', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;qzCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,WAAYX,IAG1C,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,WAAYV,IAO1C,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a9b17f8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a58be6ee58cf7ef63ca84e11077522c944b63cf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:10:46 +0000 Subject: [PATCH 47/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 55 files changed, 6206 insertions(+), 6233 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6edf36c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:30:16.016Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 9d8fef1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -264,15 +257,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d7542c7..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 8c939a4..980cfc4 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..eaad80b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f9943ac --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6057e2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 041cde3..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..56b7c32 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From feab0b3eb8031db2ef5414c6d5a9351cdc8ad462 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:09:08 +0000 Subject: [PATCH 48/89] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a50c94f..041cde3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.1.0", "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From e64a20f846f5de74294d43ffd7ad35c04b410c8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:31:51 +0000 Subject: [PATCH 49/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 980cfc4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( `@stdlib/ndarray/zeros` ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index eaad80b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f9943ac..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 56b7c32..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ce18db61ef639ee0fd0d7023d1478c297c5de032 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:32:25 +0000 Subject: [PATCH 50/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 55 files changed, 6206 insertions(+), 6238 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f4f1593..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:24:51.040Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 9d8fef1..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..eaad80b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f9943ac --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6057e2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 041cde3..a6ff75e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/ndarray-dtype": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/buffer-ctor": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b52cbbd --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 7512be64ed398e701ae674a7c0b82fc4570d6e34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:18:08 +0000 Subject: [PATCH 51/89] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index befe2a6..70b017a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.0", "@stdlib/ndarray-order": "^0.2.0", "@stdlib/ndarray-shape": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From f20533832ad8ad6c2b486394bc5b83509e4129e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:49:01 +0000 Subject: [PATCH 52/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index eaad80b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.1.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f9943ac..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b52cbbd..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e38cdd1b74e222195ac0bdfdadf4486f6f791f18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:49:49 +0000 Subject: [PATCH 53/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 82 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 --- 54 files changed, 6206 insertions(+), 6241 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index fccae29..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ac8b778 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f9943ac --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6057e2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 70b017a..88b3ff8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-ndarray-like": "^0.2.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.0", - "@stdlib/assert-is-plain-object": "^0.2.0", - "@stdlib/buffer-alloc-unsafe": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/ndarray-ctor": "^0.2.0", - "@stdlib/ndarray-dtype": "^0.2.0", - "@stdlib/ndarray-order": "^0.2.0", - "@stdlib/ndarray-shape": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-int16": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-int8": "^0.2.0", - "@stdlib/array-uint16": "^0.2.0", - "@stdlib/array-uint32": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-instance-of": "^0.2.0", - "@stdlib/buffer-ctor": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/ndarray-base-zeros": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.2.0", - "@stdlib/ndarray-zeros": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..90d73ca --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 423aa195c1d33c5b3a50579784e0b6335af6be83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:37:14 +0000 Subject: [PATCH 54/89] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f326f27..b5c128b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.0-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -139,7 +139,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.0-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 11bf2197523ccd27732cbc81680acf068a14e0e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:37:14 +0000 Subject: [PATCH 55/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b5c128b..9907885 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.0-esm/index.mjs'; ``` @@ -139,7 +144,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.0-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From c077281cb47d37221563a7c4f2dca26b9fe74210 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:01:24 +0000 Subject: [PATCH 56/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 671ad34..7b25552 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From d79fb8eecceccbf8aa2e3a18cdf89d992d61ee82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:18:42 +0000 Subject: [PATCH 57/89] Remove files --- index.d.ts | 1093 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7275 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ac8b778..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import{primitives as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function v(v){var b,f,g,y,c,u,x,w;if(!e(v))throw new TypeError(h("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",v));if(y={},arguments.length>1){if(!s(b=arguments[1]))throw new TypeError(h("invalid argument. Options argument must be an object. Value: `%s`.",b));if(f=r(b,"dtype")?b.dtype:m(v),r(b,"shape")){if("number"==typeof(w=b.shape)&&(w=[w]),!t(w))throw new TypeError(h("invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.","shape",w))}else w=o(v);g=r(b,"order")?b.order:a(v),r(b,"mode")&&(y.mode=b.mode),r(b,"submode")&&(y.submode=b.submode)}else f=m(v),w=o(v),g=a(v);return w.length>0?(u=d(w),x=n(w,g)):(u=1,x=[0]),c="binary"===f?l(u):j(u,f),new p(f,c,w,x,i(w,x),g,y)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f9943ac..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4yCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,gFAAiFX,IAG/G,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,qEAAsEV,IAOpG,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,+GAAgH,QAASH,SAGvJA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 90d73ca..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4ca0ba4989dfc4e9ffc27ade92e2350bb68eac91 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:19:11 +0000 Subject: [PATCH 58/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 -- benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 83 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 ---- 54 files changed, 4871 insertions(+), 6236 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7998552 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 7b25552..3138f89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.0", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cd49b89 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 483d7c1113d2641737a5ada77d928b57bb414ce6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:57:19 +0000 Subject: [PATCH 59/89] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f534212..eaaaf80 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.1-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -139,7 +139,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.1-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 0095e4d67d634df5627ade07d88c25436b73a966 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:57:19 +0000 Subject: [PATCH 60/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eaaaf80..0d58f71 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.1-esm/index.mjs'; ``` @@ -139,7 +144,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.2.1-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 4aa9269687f69fa9ad39e6b8f7b6f7931e6bfa88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:24:37 +0000 Subject: [PATCH 61/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index ad5f858..d28c74c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From a6660b25d092ed3c1cf21992aafd3c01d34d8937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:10:03 +0000 Subject: [PATCH 62/89] Remove files --- index.d.ts | 1093 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5940 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7998552..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cd49b89..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 058cc59ab270375b7aca514b55878e57431b6a23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:10:19 +0000 Subject: [PATCH 63/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 -- benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 83 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 ---- 55 files changed, 4871 insertions(+), 6238 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 73b9627..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:04:01.310Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7a9a5ee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index d28c74c..3138f89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5e726f9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 956b087d56cee6478f6de7eb64431dddf60b7e94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:41:24 +0000 Subject: [PATCH 64/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index ad5f858..d28c74c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 3b346fbd6b37b13a0d352c7ad6c8a8a538e60723 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:13:45 +0000 Subject: [PATCH 65/89] Remove files --- index.d.ts | 1093 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5940 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7a9a5ee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5e726f9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eeb4d31feb52bdbd24bc0450d1dfa79b000c4d26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:14:05 +0000 Subject: [PATCH 66/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 -- benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 83 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 ---- 55 files changed, 4871 insertions(+), 6241 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e69f318..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:20:00.361Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7a9a5ee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index d28c74c..3138f89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5e726f9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From b257e8665148dc34025333d7c9973af865bb13e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:54:48 +0000 Subject: [PATCH 67/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index ad5f858..d28c74c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 1e8e4f748b341dfbf72d08c0f0c215092c8552a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:24:28 +0000 Subject: [PATCH 68/89] Remove files --- index.d.ts | 1093 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5940 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7a9a5ee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5e726f9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 070e014d6b51192beabf23cad0d4eb6e5de1a4d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:24:46 +0000 Subject: [PATCH 69/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 294 -- benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 193 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 83 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 910 ---- 54 files changed, 4871 insertions(+), 6242 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8505014..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,294 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 3cc4d4c..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0fa0a76..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = zeros( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 2cbc0a1..266ec27 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7a9a5ee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index d28c74c..3138f89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5e726f9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 58f5287..0000000 --- a/test/test.js +++ /dev/null @@ -1,910 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From c45a69fded0ae16c541465b3124cf3e52010b1d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:32:58 +0000 Subject: [PATCH 70/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index ea48570..e1587f2 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 181a163262cbbc1eb480ef2cfea8864c0ed46e43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:34:02 +0000 Subject: [PATCH 71/89] Remove files --- index.d.ts | 1093 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5940 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 266ec27..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1093 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7a9a5ee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5e726f9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4c06983bb13bd003491cd1621aa0f64d90e7cce3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 23:34:18 +0000 Subject: [PATCH 72/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 55 files changed, 4871 insertions(+), 6530 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7a9a5ee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index e1587f2..3138f89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/buffer-ctor": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-empty": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-empty": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5e726f9 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 552731e3407467546b06a78c7a5cc8b845e10622 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:27:33 +0000 Subject: [PATCH 73/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index c443c30..63b414e 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.1", "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7ecfc1a28ba94a4eab9e8786dad976999a43daca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:50:05 +0000 Subject: [PATCH 74/89] Remove files --- index.d.ts | 1271 ------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6118 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f74c13e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1271 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface BoolOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'bool'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'bool' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'bool' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: boolndarray, options?: Options ): boolndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: genericndarray, options?: Options ): genericndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized boolean array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'bool' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: ndarray, options: BoolOptions ): boolndarray; - -/** -* Creates an uninitialized generic array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'generic' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options: GenericOptions ): genericndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7a9a5ee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5e726f9..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d16b3c9a040a6078e219ddecc034c89aa3bac070 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:50:23 +0000 Subject: [PATCH 75/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 222 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 55 files changed, 4871 insertions(+), 6636 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f34b09 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 63b414e..a8da4d0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/ndarray-dtype": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-empty": "^0.2.1", - "@stdlib/ndarray-base-zeros": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-empty": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..663cf8f --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 0304ebcf2e29a70c443baa538384fd522e37ab4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:55:01 +0000 Subject: [PATCH 76/89] Update README.md for ESM bundle v0.3.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 25e4db6..bd3b9b9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.3.0-esm/index.mjs'; ``` #### emptyLike( x\[, options] ) @@ -139,7 +139,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.3.0-esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 31970e242ca8b9f3b5de28de5e5627b2b3f8caf6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:55:01 +0000 Subject: [PATCH 77/89] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd3b9b9..4b66cfa 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-empty-like/tags). For example, + ```javascript import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.3.0-esm/index.mjs'; ``` @@ -139,7 +144,7 @@ dt = y.dtype; import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import empty from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@esm/index.mjs'; -import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@v0.3.0-esm/index.mjs'; +import emptyLike from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@esm/index.mjs'; // Get a list of data types: var dt = dtypes(); From 22bc4101e4b5d9867a8ee8ca8267877d393f2a42 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:31:54 +0000 Subject: [PATCH 78/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 917e5cb..0198283 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.2", "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 8090a08165affaeab5659d2b246b46ad402ba610 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:27:37 +0000 Subject: [PATCH 79/89] Remove files --- index.d.ts | 1271 ------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6118 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f74c13e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1271 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface BoolOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'bool'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'bool' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'bool' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: boolndarray, options?: Options ): boolndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: genericndarray, options?: Options ): genericndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized boolean array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'bool' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: ndarray, options: BoolOptions ): boolndarray; - -/** -* Creates an uninitialized generic array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'generic' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options: GenericOptions ): genericndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f34b09..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 663cf8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8c50b4bc3acb3f5b6f5483195d1d95248ee4058c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:27:57 +0000 Subject: [PATCH 80/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 98 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 56 files changed, 4871 insertions(+), 6513 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index aa531bb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:13:51.658Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..985bcea --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 0198283..a8da4d0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-dtype": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-empty": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..db364f0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From de2703ae59b50969b392643bcc302399caae31d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:36:21 +0000 Subject: [PATCH 81/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index adcf989..68af0e9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.2", "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7e7186bf7ce279e753f3003b94bc83a55bd7ecd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:41:31 +0000 Subject: [PATCH 82/89] Remove files --- index.d.ts | 1271 ------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6118 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f74c13e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1271 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface BoolOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'bool'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'bool' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'bool' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: boolndarray, options?: Options ): boolndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: genericndarray, options?: Options ): genericndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized boolean array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'bool' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: ndarray, options: BoolOptions ): boolndarray; - -/** -* Creates an uninitialized generic array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'generic' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options: GenericOptions ): genericndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 985bcea..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db364f0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 52b878a75d65326fd379e9132a9305efaa93a7b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:42:05 +0000 Subject: [PATCH 83/89] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 221 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 57 files changed, 4871 insertions(+), 6741 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5cdc763..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T01:35:49.718Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index dbc7c41..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..50452e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 68af0e9..a8da4d0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-dtype": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-empty": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..db364f0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From b22a75c998102acf6829b52afe149620cf4099e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:22:34 +0000 Subject: [PATCH 84/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 6057e2a..e20ccaf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -83,13 +83,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -102,7 +102,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index adcf989..68af0e9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-dtype": "^0.2.2", "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 70383e86f038e38b590b9d05188a32cc3546de24 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:31:56 +0000 Subject: [PATCH 85/89] Remove files --- index.d.ts | 1271 ------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6118 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f74c13e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1271 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface BoolOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'bool'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'bool' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'bool' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: boolndarray, options?: Options ): boolndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: genericndarray, options?: Options ): genericndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized boolean array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'bool' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: ndarray, options: BoolOptions ): boolndarray; - -/** -* Creates an uninitialized generic array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'generic' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options: GenericOptions ): genericndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 50452e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db364f0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f0c88369a5257c2c036cff467775da1be1141497 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:32:26 +0000 Subject: [PATCH 86/89] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 221 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 146 - package.json | 85 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 57 files changed, 4871 insertions(+), 6744 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 01ef7a2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:21:04.231Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index be706f7..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 444c1c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=q(function(P,g){ -var b=require('@stdlib/assert-is-ndarray-like/dist'),h=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,n=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),f=require('@stdlib/ndarray-shape/dist'),l=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),k=require('@stdlib/array-empty/dist'),E=require('@stdlib/buffer-alloc-unsafe/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist');function A(a){var e,i,t,m,s,v,o,u,r;if(!b(a))throw new TypeError(p('1dZ5t',a));if(s={},arguments.length>1){if(e=arguments[1],!h(e))throw new TypeError(p('1dZ2V',e));if(n(e,"dtype")?i=e.dtype:i=d(a),n(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(p('1dZDs',"shape",r))}else r=f(a);n(e,"order")?t=e.order:t=l(a),n(e,"mode")&&(s.mode=e.mode),n(e,"submode")&&(s.submode=e.submode)}else i=d(a),r=f(a),t=l(a);return m=r.length,m>0?(o=T(r),u=c(r,t)):(o=1,u=[0]),i==="binary"?v=E(o):v=k(o,i),new j(i,v,r,u,O(r,u),t,s)}g.exports=A -});var L=y();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e54e8ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACf,EAAee,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACtB,EAA2BsB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKArB,EAAO,QAAUe,ICrGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..50452e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bb30112 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e20ccaf..0000000 --- a/lib/main.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( typeof sh === 'number' ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) ) { - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 68af0e9..a8da4d0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,64 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-dtype": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-empty": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..db364f0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -}); From 20c0c56f9e079d106712309d0d4e803993142bd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:06:03 +0000 Subject: [PATCH 87/89] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 372baf0..d1d46d2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -35,7 +35,7 @@ var getOrder = require( '@stdlib/ndarray-order' ); var ndarray = require( '@stdlib/ndarray-ctor' ); var emptyArray = require( '@stdlib/array-empty' ); var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -85,13 +85,13 @@ function emptyLike( x ) { var sh; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( '1dZ5t', x ) ); } opts = {}; if ( arguments.length > 1 ) { options = arguments[ 1 ]; if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1dZ2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { dtype = options.dtype; @@ -104,7 +104,7 @@ function emptyLike( x ) { sh = [ sh ]; } if ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) ); + throw new TypeError( format( '1dZDs', 'shape', sh ) ); } } else { sh = getShape( x ); diff --git a/package.json b/package.json index 9a1b6b2..4f2900e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/ndarray-dtype": "^0.2.2", "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7d12c3ee8dc0c19c646ad6ff27ac086af2ccb97e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:06:30 +0000 Subject: [PATCH 88/89] Remove files --- index.d.ts | 1271 ------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6118 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f74c13e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1271 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array shape. - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred shape. - */ - shape?: Shape | number; - - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - * - * ## Notes - * - * - If provided, this option overrides the input array's inferred order. - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). - */ - submode?: Array; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface Int32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int32'; -} - -/** -* Interface describing function options. -*/ -interface Int16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int16'; -} - -/** -* Interface describing function options. -*/ -interface Int8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'int8'; -} - -/** -* Interface describing function options. -*/ -interface Uint32Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint32'; -} - -/** -* Interface describing function options. -*/ -interface Uint16Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint16'; -} - -/** -* Interface describing function options. -*/ -interface Uint8Options extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8'; -} - -/** -* Interface describing function options. -*/ -interface Uint8COptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'uint8c'; -} - -/** -* Interface describing function options. -*/ -interface BoolOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'bool'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing function options. -*/ -interface OptionsWithDType extends Options { - /** - * Underlying data type. - * - * ## Notes - * - * - This option overrides the input array's inferred data type. - */ - dtype: DataType; -} - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: float64ndarray, options?: Options ): float64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: float32ndarray, options?: Options ): float32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex128' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex128' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: complex128ndarray, options?: Options ): complex128ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'complex64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'complex64' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: complex64ndarray, options?: Options ): complex64ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: int32ndarray, options?: Options ): int32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: int16ndarray, options?: Options ): int16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'int8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'int8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: int8ndarray, options?: Options ): int8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint32' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint32' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: uint32ndarray, options?: Options ): uint32ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint16' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint16' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: uint16ndarray, options?: Options ): uint16ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: uint8ndarray, options?: Options ): uint8ndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'uint8c' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'uint8c' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: uint8cndarray, options?: Options ): uint8cndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'bool' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'bool' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: boolndarray, options?: Options ): boolndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var empty = require( '@stdlib/ndarray-empty' ); -* -* var x = empty( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: genericndarray, options?: Options ): genericndarray; - -/** -* Creates an uninitialized double-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'generic' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x, { -* 'dtype': 'float64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float64' -*/ -declare function emptyLike( x: ndarray, options: Float64Options ): float64ndarray; - -/** -* Creates an uninitialized single-precision floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'float32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'float32' -*/ -declare function emptyLike( x: ndarray, options: Float32Options ): float32ndarray; - -/** -* Creates an uninitialized double-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex128' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex128' -*/ -declare function emptyLike( x: ndarray, options: Complex128Options ): complex128ndarray; - -/** -* Creates an uninitialized single-precision complex floating-point array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'complex64' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'complex64' -*/ -declare function emptyLike( x: ndarray, options: Complex64Options ): complex64ndarray; - -/** -* Creates an uninitialized 32-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int32' -*/ -declare function emptyLike( x: ndarray, options: Int32Options ): int32ndarray; - -/** -* Creates an uninitialized 16-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int16' -*/ -declare function emptyLike( x: ndarray, options: Int16Options ): int16ndarray; - -/** -* Creates an uninitialized 8-bit signed integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'int8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'int8' -*/ -declare function emptyLike( x: ndarray, options: Int8Options ): int8ndarray; - -/** -* Creates an uninitialized 32-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint32' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint32' -*/ -declare function emptyLike( x: ndarray, options: Uint32Options ): uint32ndarray; - -/** -* Creates an uninitialized 16-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint16' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint16' -*/ -declare function emptyLike( x: ndarray, options: Uint16Options ): uint16ndarray; - -/** -* Creates an uninitialized 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8' -*/ -declare function emptyLike( x: ndarray, options: Uint8Options ): uint8ndarray; - -/** -* Creates an uninitialized clamped 8-bit unsigned integer array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'uint8c' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'uint8c' -*/ -declare function emptyLike( x: ndarray, options: Uint8COptions ): uint8cndarray; - -/** -* Creates an uninitialized boolean array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'bool' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'bool' -*/ -declare function emptyLike( x: ndarray, options: BoolOptions ): boolndarray; - -/** -* Creates an uninitialized generic array having the same shape as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'float64' -* -* var y = emptyLike( x, { -* 'dtype': 'generic' -* }); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options: GenericOptions ): genericndarray; - -/** -* Creates an uninitialized array having the same shape and data type as a provided input ndarray. -* -* @param x - input array -* @param options - options -* @param options.dtype - output array data type -* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style) -* @param options.shape - output array shape -* @param options.mode - specifies how to handle a linear index which exceeds array dimensions -* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @returns output array -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ], { -* 'dtype': 'float64' -* }); -* // returns -* -* var sh = x.shape; -* // returns [ 2, 2 ] -* -* var dt = x.dtype; -* // returns 'generic' -* -* var y = emptyLike( x ); -* // returns -* -* sh = y.shape; -* // returns [ 2, 2 ] -* -* dt = y.dtype; -* // returns 'generic' -*/ -declare function emptyLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray; - - -// EXPORTS // - -export = emptyLike; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 50452e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function v(v){var f,b,y,g,c,x,u,w;if(!s(v))throw new TypeError(l("1dZ5t",v));if(g={},arguments.length>1){if(!e(f=arguments[1]))throw new TypeError(l("1dZ2V",f));if(b=t(f,"dtype")?f.dtype:m(v),t(f,"shape")){if("number"==typeof(w=f.shape)&&(w=[w]),!r(w))throw new TypeError(l("1dZDs","shape",w))}else w=o(v);y=t(f,"order")?f.order:p(v),t(f,"mode")&&(g.mode=f.mode),t(f,"submode")&&(g.submode=f.submode)}else b=m(v),w=o(v),y=p(v);return w.length>0?(x=n(w),u=d(w,y)):(x=1,u=[0]),c="binary"===b?h(x):a(x,b),new j(b,c,w,u,i(w,u),y,g)}export{v as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bb30112..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNonNegativeIntegerArray","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;4zCAyEA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAHmB,iBADnBO,EAAKP,EAAQgB,SAEZT,EAAK,CAAEA,KAEFU,EAA2BV,GAChC,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKW,EAAUnB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERiB,EAAUpB,GAEde,EAAYd,EAAS,UACzBG,EAAKiB,KAAOpB,EAAQoB,MAEhBN,EAAYd,EAAS,aACzBG,EAAKkB,QAAUrB,EAAQqB,QAE1B,MACEpB,EAAQc,EAAUhB,GAClBQ,EAAKW,EAAUnB,GACfG,EAAQiB,EAAUpB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMiB,EAAOf,GACbD,EAAKiB,EAAehB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEuB,EAAanB,GAEboB,EAAYpB,EAAKJ,GAEjB,IAAIyB,EAASzB,EAAOG,EAAKG,EAAID,EAAIqB,EAAgBpB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db364f0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 89d34f2d53e1211493f2299f4624ff36f1102ac2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:06:57 +0000 Subject: [PATCH 89/89] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 265 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 317 -- benchmark/benchmark.size.bool.js | 95 - benchmark/benchmark.size.complex128.js | 95 - benchmark/benchmark.size.complex64.js | 95 - benchmark/benchmark.size.float32.js | 95 - benchmark/benchmark.size.float64.js | 95 - benchmark/benchmark.size.generic.js | 95 - benchmark/benchmark.size.int16.js | 95 - benchmark/benchmark.size.int32.js | 95 - benchmark/benchmark.size.int8.js | 95 - benchmark/benchmark.size.uint16.js | 95 - benchmark/benchmark.size.uint32.js | 95 - benchmark/benchmark.size.uint8.js | 95 - benchmark/benchmark.size.uint8c.js | 95 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 83 - docs/types/test.ts | 199 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 148 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 948 ---- 56 files changed, 4871 insertions(+), 6791 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.bool.js delete mode 100644 benchmark/benchmark.size.complex128.js delete mode 100644 benchmark/benchmark.size.complex64.js delete mode 100644 benchmark/benchmark.size.float32.js delete mode 100644 benchmark/benchmark.size.float64.js delete mode 100644 benchmark/benchmark.size.generic.js delete mode 100644 benchmark/benchmark.size.int16.js delete mode 100644 benchmark/benchmark.size.int32.js delete mode 100644 benchmark/benchmark.size.int8.js delete mode 100644 benchmark/benchmark.size.uint16.js delete mode 100644 benchmark/benchmark.size.uint32.js delete mode 100644 benchmark/benchmark.size.uint8.js delete mode 100644 benchmark/benchmark.size.uint8c.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index be706f7..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 80a341b..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3b4d557..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '22 10 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < dt.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -269,15 +260,15 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-empty-like/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty +[@stdlib/ndarray/empty]: https://github.com/stdlib-js/ndarray-empty/tree/esm -[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like +[@stdlib/ndarray/zeros-like]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3aae2e6..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=float64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'float32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex128', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'complex64', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint32', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint16', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'int8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'uint8c', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var x; - var y; - var i; - - x = empty( 'bool', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var x; - var y; - var i; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - y = emptyLike( x ); - if ( y.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( y ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.bool.js b/benchmark/benchmark.size.bool.js deleted file mode 100644 index 460b3d2..0000000 --- a/benchmark/benchmark.size.bool.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = empty( 'bool', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex128.js b/benchmark/benchmark.size.complex128.js deleted file mode 100644 index 427ef7d..0000000 --- a/benchmark/benchmark.size.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex128', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.complex64.js b/benchmark/benchmark.size.complex64.js deleted file mode 100644 index cb9248b..0000000 --- a/benchmark/benchmark.size.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'complex64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float32.js b/benchmark/benchmark.size.float32.js deleted file mode 100644 index b1028f6..0000000 --- a/benchmark/benchmark.size.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.float64.js b/benchmark/benchmark.size.float64.js deleted file mode 100644 index c6da862..0000000 --- a/benchmark/benchmark.size.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'float64', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.generic.js b/benchmark/benchmark.size.generic.js deleted file mode 100644 index a4eb936..0000000 --- a/benchmark/benchmark.size.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'generic', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int16.js b/benchmark/benchmark.size.int16.js deleted file mode 100644 index d9b4cc3..0000000 --- a/benchmark/benchmark.size.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int32.js b/benchmark/benchmark.size.int32.js deleted file mode 100644 index 454f04f..0000000 --- a/benchmark/benchmark.size.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.int8.js b/benchmark/benchmark.size.int8.js deleted file mode 100644 index 37b3471..0000000 --- a/benchmark/benchmark.size.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'int8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint16.js b/benchmark/benchmark.size.uint16.js deleted file mode 100644 index f21e7fc..0000000 --- a/benchmark/benchmark.size.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint16', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint32.js b/benchmark/benchmark.size.uint32.js deleted file mode 100644 index 51fe018..0000000 --- a/benchmark/benchmark.size.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint32', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8.js b/benchmark/benchmark.size.uint8.js deleted file mode 100644 index 565ea56..0000000 --- a/benchmark/benchmark.size.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,size='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.size.uint8c.js b/benchmark/benchmark.size.uint8c.js deleted file mode 100644 index 79bb897..0000000 --- a/benchmark/benchmark.size.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( 'uint8c', [ len ], 'row-major' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,size='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5bed14d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like" -%% click B href "https://github.com/stdlib-js/ndarray-empty-like/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-empty-like/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-empty-like/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-empty-like/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-empty-like/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/empty-like -[production-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-empty-like/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-empty-like/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index bb26c5c..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import emptyLike from '../docs/types/index'; -export = emptyLike; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a5b05d3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var y=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var q=y(function(C,g){ -var b=require('@stdlib/assert-is-number/dist').isPrimitive,h=require('@stdlib/assert-is-ndarray-like/dist'),c=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,O=require('@stdlib/assert-is-empty-collection/dist'),s=require('@stdlib/assert-has-own-property/dist'),E=require('@stdlib/ndarray-base-shape2strides/dist'),T=require('@stdlib/ndarray-base-strides2offset/dist'),j=require('@stdlib/ndarray-base-numel/dist'),d=require('@stdlib/ndarray-dtype/dist'),l=require('@stdlib/ndarray-shape/dist'),f=require('@stdlib/ndarray-order/dist'),k=require('@stdlib/ndarray-ctor/dist'),N=require('@stdlib/array-empty/dist'),P=require('@stdlib/buffer-alloc-unsafe/dist'),m=require('@stdlib/error-tools-fmtprodmsg/dist');function A(i){var e,a,t,p,n,v,o,u,r;if(!h(i))throw new TypeError(m('1dZ5t',i));if(n={},arguments.length>1){if(e=arguments[1],!c(e))throw new TypeError(m('1dZ2V',e));if(s(e,"dtype")?a=e.dtype:a=d(i),s(e,"shape")){if(r=e.shape,b(r)&&(r=[r]),!w(r)&&!O(r))throw new TypeError(m('1dZDs',"shape",r))}else r=l(i);s(e,"order")?t=e.order:t=f(i),s(e,"mode")&&(n.mode=e.mode),s(e,"submode")&&(n.submode=e.submode)}else a=d(i),r=l(i),t=f(i);return p=r.length,p>0?(o=j(r),u=E(r,t)):(o=1,u=[0]),a==="binary"?v=P(o):v=N(o,a),new k(a,v,r,u,T(r,u),t,n)}g.exports=A -});var L=q();module.exports=L; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 92e3538..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar emptyArray = require( '@stdlib/array-empty' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( isNumber( sh ) ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = emptyLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-empty-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var emptyLike = require( '@stdlib/ndarray-empty-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAoB,QAAS,oCAAqC,EAClEC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAc,QAAS,6BAA8B,EACrDC,EAAS,QAAS,uBAAwB,EAsC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACzB,EAAegB,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAAChB,EAAegB,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKb,EAAYa,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQV,EAAUQ,CAAE,EAEhBZ,EAAYa,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACRlB,EAAU0B,CAAG,IACjBA,EAAK,CAAEA,CAAG,GAEN,CAACvB,EAA2BuB,CAAG,GAAK,CAACtB,EAAmBsB,CAAG,EAC/D,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKhB,EAAUO,CAAE,EAEbZ,EAAYa,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQT,EAAUM,CAAE,EAEhBZ,EAAYa,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBb,EAAYa,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,QAEzB,MACCC,EAAQV,EAAUQ,CAAE,EACpBS,EAAKhB,EAAUO,CAAE,EACjBG,EAAQT,EAAUM,CAAE,EAErB,OAAAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMhB,EAAOkB,CAAG,EAChBD,EAAKnB,EAAeoB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAELN,IAAU,SACdI,EAAMT,EAAaU,CAAI,EAEvBD,EAAMV,EAAYW,EAAKL,CAAM,EAEvB,IAAIP,EAASO,EAAOI,EAAKG,EAAID,EAAIlB,EAAgBmB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAvB,EAAO,QAAUiB,ICvGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNumber", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "isEmptyCollection", "hasOwnProp", "shape2strides", "strides2offset", "numel", "getDType", "getShape", "getOrder", "ndarray", "emptyArray", "allocUnsafe", "format", "emptyLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e155fa8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x[, options] ) - Returns an uninitialized ndarray having the same shape and data type as a - provided input ndarray. - - The function infers the following attributes from the input array: - - - shape: array shape. - - dtype: underlying array data type. - - order: whether the array order is row-major (C-style) or column-major - (Fortran-style). - - In browser environments, the function always returns zero-filled ndarrays. - - If `dtype` is 'generic', the function always returns a zero-filled ndarray. - - For returned ndarrays whose underlying memory is *not* initialized, memory - contents are unknown and may contain *sensitive* data. - - Parameters - ---------- - x: ndarray - Input array. - - options: Object (optional) - Options. - - options.shape: ArrayLikeObject|integer (optional) - Array shape. Overrides the input array's inferred shape. - - options.dtype: string (optional) - Array data type. Overrides the input array's inferred data type. - - options.order: string (optional) - Array order (either 'row-major' (C-style) or 'column-major' (Fortran- - style)). Overrides the input array's inferred order. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.submode: Array (optional) - Specifies how to handle subscripts which exceed array dimensions. If a - mode for a corresponding dimension is equal to 'throw', an ndarray - instance throws an error when a subscript exceeds array dimensions. If - equal to 'normalize', an ndarray instance normalizes negative - subscripts and throws an error when a subscript exceeds array - dimensions. If equal to 'wrap', an ndarray instance wraps around - subscripts exceeding array dimensions using modulo arithmetic. If equal - to 'clamp', an ndarray instance sets a subscript exceeding array - dimensions to either `0` (minimum index) or the maximum index. If the - number of modes is fewer than the number of dimensions, the function - recycles modes using modulo arithmetic. Default: [ options.mode ]. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' ) - - > var sh = x.shape - [ 2, 2 ] - > var dt = x.dtype - 'float64' - > var y = {{alias}}( x ) - - > sh = y.shape - [ 2, 2 ] - > dt = y.dtype - 'float64' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a7a7b5f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zeros = require( '@stdlib/ndarray-base-zeros' ); -import empty = require( '@stdlib/ndarray-base-empty' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - const sh = [ 2, 2 ]; - const ord = 'row-major'; - - emptyLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), {} ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray - emptyLike( empty( 'bool', sh, ord ), { 'order': 'column-major' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType genericndarray - - - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'bool' } ); // $ExpectType boolndarray - emptyLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type... -{ - emptyLike( '10' ); // $ExpectError - emptyLike( 10 ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( [] ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument is not an options object... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, '10' ); // $ExpectError - emptyLike( x, 10 ); // $ExpectError - emptyLike( x, false ); // $ExpectError - emptyLike( x, true ); // $ExpectError - emptyLike( x, [] ); // $ExpectError - emptyLike( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'dtype': '10' } ); // $ExpectError - emptyLike( x, { 'dtype': 10 } ); // $ExpectError - emptyLike( x, { 'dtype': null } ); // $ExpectError - emptyLike( x, { 'dtype': false } ); // $ExpectError - emptyLike( x, { 'dtype': true } ); // $ExpectError - emptyLike( x, { 'dtype': [] } ); // $ExpectError - emptyLike( x, { 'dtype': {} } ); // $ExpectError - emptyLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `order` option which is not a valid order... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'order': '10' } ); // $ExpectError - emptyLike( x, { 'order': 10 } ); // $ExpectError - emptyLike( x, { 'order': false } ); // $ExpectError - emptyLike( x, { 'order': true } ); // $ExpectError - emptyLike( x, { 'order': [] } ); // $ExpectError - emptyLike( x, { 'order': {} } ); // $ExpectError - emptyLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `shape` option which is not a valid shape... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'shape': '10' } ); // $ExpectError - emptyLike( x, { 'shape': false } ); // $ExpectError - emptyLike( x, { 'shape': true } ); // $ExpectError - emptyLike( x, { 'shape': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'shape': {} } ); // $ExpectError - emptyLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'mode': '5' } ); // $ExpectError - emptyLike( x, { 'mode': 5 } ); // $ExpectError - emptyLike( x, { 'mode': false } ); // $ExpectError - emptyLike( x, { 'mode': true } ); // $ExpectError - emptyLike( x, { 'mode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'mode': {} } ); // $ExpectError - emptyLike( x, { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `submode` option which is not valid... -{ - const x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - - emptyLike( x, { 'submode': '5' } ); // $ExpectError - emptyLike( x, { 'submode': 5 } ); // $ExpectError - emptyLike( x, { 'submode': false } ); // $ExpectError - emptyLike( x, { 'submode': true } ); // $ExpectError - emptyLike( x, { 'submode': [ '5' ] } ); // $ExpectError - emptyLike( x, { 'submode': {} } ); // $ExpectError - emptyLike( x, { 'submode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike(); // $ExpectError - emptyLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bebd8c0..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var empty = require( '@stdlib/ndarray-empty' ); -var emptyLike = require( './../lib' ); - -// Get a list of data types: -var dt = dtypes(); - -// Generate uninitialized arrays... -var x; -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - x = empty( [ 2, 2 ], { - 'dtype': dt[ i ] - }); - y = emptyLike( x ); - console.log( y.data ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 983d73e..f74c13e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b2da671 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import{primitives as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer-array@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtype@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-empty@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function b(b){var c,g,y,x,u,w,E,T;if(!e(b))throw new TypeError(f("1dZ5t",b));if(x={},arguments.length>1){if(!t(c=arguments[1]))throw new TypeError(f("1dZ2V",c));if(g=i(c,"dtype")?c.dtype:p(b),i(c,"shape")){if(T=c.shape,s(T)&&(T=[T]),!r(T)&&!d(T))throw new TypeError(f("1dZDs","shape",T))}else T=j(b);y=i(c,"order")?c.order:l(b),i(c,"mode")&&(x.mode=c.mode),i(c,"submode")&&(x.submode=c.submode)}else g=p(b),T=j(b),y=l(b);return T.length>0?(w=o(T),E=m(T,y)):(w=1,E=[0]),u="binary"===g?v(w):h(w,g),new a(g,u,T,E,n(T,E),y,x)}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e556c8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport { primitives as isNonNegativeIntegerArray } from '@stdlib/assert-is-nonnegative-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport numel from '@stdlib/ndarray-base-numel';\nimport getDType from '@stdlib/ndarray-dtype';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport emptyArray from '@stdlib/array-empty';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns \n*\n* var y = emptyLike( x );\n* // returns \n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction emptyLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dZ5t', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1dZ2V', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( isNumber( sh ) ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len\n\t\t\t\tthrow new TypeError( format( '1dZDs', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tif ( dtype === 'binary' ) {\n\t\tbuf = allocUnsafe( len );\n\t} else {\n\t\tbuf = emptyArray( len, dtype );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n"],"names":["emptyLike","x","options","dtype","order","opts","buf","len","st","sh","isndarrayLike","TypeError","format","arguments","length","isPlainObject","hasOwnProp","getDType","shape","isNumber","isNonNegativeIntegerArray","isEmptyCollection","getShape","getOrder","mode","submode","numel","shape2strides","allocUnsafe","emptyArray","ndarray","strides2offset"],"mappings":";;2gDA2EA,SAASA,EAAWC,GACnB,IAAIC,EACAC,EACAC,EAEAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeT,GACpB,MAAM,IAAIU,UAAWC,EAAQ,QAASX,IAGvC,GADAI,EAAO,CAAA,EACFQ,UAAUC,OAAS,EAAI,CAE3B,IAAMC,EADNb,EAAUW,UAAW,IAEpB,MAAM,IAAIF,UAAWC,EAAQ,QAASV,IAOvC,GAJCC,EADIa,EAAYd,EAAS,SACjBA,EAAQC,MAERc,EAAUhB,GAEde,EAAYd,EAAS,UAKzB,GAJAO,EAAKP,EAAQgB,MACRC,EAAUV,KACdA,EAAK,CAAEA,KAEFW,EAA2BX,KAASY,EAAmBZ,GAC5D,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASH,SAGhDA,EAAKa,EAAUrB,GAGfG,EADIY,EAAYd,EAAS,SACjBA,EAAQE,MAERmB,EAAUtB,GAEde,EAAYd,EAAS,UACzBG,EAAKmB,KAAOtB,EAAQsB,MAEhBR,EAAYd,EAAS,aACzBG,EAAKoB,QAAUvB,EAAQuB,QAE1B,MACEtB,EAAQc,EAAUhB,GAClBQ,EAAKa,EAAUrB,GACfG,EAAQmB,EAAUtB,GAgBnB,OAdQQ,EAAGK,OACE,GACZP,EAAMmB,EAAOjB,GACbD,EAAKmB,EAAelB,EAAIL,KAGxBG,EAAM,EACNC,EAAK,CAAE,IAGPF,EADc,WAAVH,EACEyB,EAAarB,GAEbsB,EAAYtB,EAAKJ,GAEjB,IAAI2B,EAAS3B,EAAOG,EAAKG,EAAID,EAAIuB,EAAgBtB,EAAID,GAAMJ,EAAOC,EAC1E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59929ec..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @module @stdlib/ndarray-empty-like -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* var emptyLike = require( '@stdlib/ndarray-empty-like' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d1d46d2..0000000 --- a/lib/main.js +++ /dev/null @@ -1,148 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var getDType = require( '@stdlib/ndarray-dtype' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var emptyArray = require( '@stdlib/array-empty' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates an uninitialized ndarray having the same shape and data type as a provided ndarray. -* -* @param {ndarray} x - input array -* @param {Options} [options] - function options -* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type) -* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order) -* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape) -* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions -* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis -* @throws {TypeError} first argument must have a recognized data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} `dtype` option must be a supported ndarray data type -* @throws {TypeError} `order` option must be a supported order -* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers -* @throws {TypeError} must provide valid options -* @returns {ndarray} ndarray -* -* @example -* var zeros = require( '@stdlib/ndarray-zeros' ); -* -* var x = zeros( [ 2, 2 ] ); -* // returns -* -* var y = emptyLike( x ); -* // returns -* -* var sh = y.shape; -* // returns [ 2, 2 ] -* -* var dt = y.dtype; -* // returns 'float64' -*/ -function emptyLike( x ) { - var options; - var dtype; - var order; - var ndims; - var opts; - var buf; - var len; - var st; - var sh; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dZ5t', x ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - options = arguments[ 1 ]; - if ( !isPlainObject( options ) ) { - throw new TypeError( format( '1dZ2V', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - dtype = options.dtype; - } else { - dtype = getDType( x ); - } - if ( hasOwnProp( options, 'shape' ) ) { - sh = options.shape; - if ( isNumber( sh ) ) { - sh = [ sh ]; - } - if ( !isNonNegativeIntegerArray( sh ) && !isEmptyCollection( sh ) ) { // eslint-disable-line max-len - throw new TypeError( format( '1dZDs', 'shape', sh ) ); - } - } else { - sh = getShape( x ); - } - if ( hasOwnProp( options, 'order' ) ) { - order = options.order; - } else { - order = getOrder( x ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - } - if ( hasOwnProp( options, 'submode' ) ) { - opts.submode = options.submode; - } - } else { - dtype = getDType( x ); - sh = getShape( x ); - order = getOrder( x ); - } - ndims = sh.length; - if ( ndims > 0 ) { - len = numel( sh ); - st = shape2strides( sh, order ); - } else { - // For 0-dimensional arrays, the buffer should contain a single element... - len = 1; - st = [ 0 ]; - } - if ( dtype === 'binary' ) { - buf = allocUnsafe( len ); - } else { - buf = emptyArray( len, dtype ); - } - return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/package.json b/package.json index 4f2900e..a8da4d0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create an uninitialized ndarray having the same shape and data type as a provided ndarray.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-empty": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-dtype": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/buffer-ctor": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-empty": "^0.3.0", - "@stdlib/ndarray-base-zeros": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-empty": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0ffe989 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cf9d470..0000000 --- a/test/test.js +++ /dev/null @@ -1,948 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Buffer = require( '@stdlib/buffer-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var zeros = require( '@stdlib/ndarray-base-zeros' ); -var empty = require( '@stdlib/ndarray-base-empty' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument having an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - { - 'data': true - } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a `dtype` option which is not a recognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `shape` option which is not a valid shape', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - true, - false, - null, - void 0, - [ '5' ], - [ 3.14 ], - [ -1 ], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'shape': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an invalid `submode` option', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), { - 'submode': [ value ] - }); - }; - } -}); - -tape( 'the function returns an uninitialized array (dtype=float64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float64, options, integer shape)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 0 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': 4, - 'dtype': 'float64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 4 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'float32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=float32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'float32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'float32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'int8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=int8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'int8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'int8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint32', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint32, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint32', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint32', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint16', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint16, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint16', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint16', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'uint8c', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=uint8c, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'uint8c', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'uint8c', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'binary', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=binary, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'binary', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'binary', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Buffer ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex128', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex128, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex128', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex128', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, inferred)', function test( t ) { - var arr; - var x; - - x = zeros( 'complex64', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=complex64, options)', function test( t ) { - var arr; - var x; - - x = zeros( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'complex64', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'complex64', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, inferred)', function test( t ) { - var arr; - var x; - - x = empty( 'bool', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an uninitialized array (dtype=bool, options)', function test( t ) { - var arr; - var x; - - x = empty( 'generic', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'bool', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'bool', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, inferred)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'generic', [ 2, 2 ], 'row-major' ); - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic, options)', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0, 0, 0, 0 ]; - - x = zeros( 'float64', [ 4 ], 'row-major' ); - arr = emptyLike( x, { - 'shape': [ 2, 2 ], - 'dtype': 'generic', - 'order': 'column-major' - }); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function guards against array having shapes containing negative dimension sizes', function test( t ) { - var x = { - 'data': [ 1, 2, 3, 4 ], - 'ndims': 3, - 'shape': [ 2, -1, 2 ], - 'strides': [ -2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'dtype': 'generic', - 'length': 0, - 'flags': {}, - 'get': noop, - 'set': noop - }; - t.throws( badValue, Error, 'throws an error' ); - - t.end(); - - function badValue() { - return emptyLike( x ); - } - - function noop() {} -}); - -tape( 'the function supports zero-dimensional arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = [ 0 ]; - - x = { - 'dtype': 'generic', - 'ndims': 0, - 'length': 0, - 'data': [ 0 ], - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports empty arrays', function test( t ) { - var expected; - var arr; - var x; - - expected = []; - - x = { - 'dtype': 'generic', - 'ndims': 3, - 'length': 0, - 'data': [], - 'shape': [ 2, 0, 2 ], - 'strides': [ 0, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'flags': {}, - 'get': noop, - 'set': noop - }; - arr = emptyLike( x ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 0, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.end(); - - function noop() {} -}); - -tape( 'the function supports specifying array index modes and submodes', function test( t ) { - var expected; - var opts; - var arr; - var x; - - expected = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - - opts = { - 'mode': 'clamp', - 'submode': [ 'wrap' ] - }; - x = zeros( 'generic', [ 2, 2, 2 ], 'row-major' ); - arr = emptyLike( x, opts ); - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); - t.strictEqual( arr.dtype, 'generic', 'returns expected value' ); - t.deepEqual( arr.shape, [ 2, 2, 2 ], 'returns expected value' ); - t.strictEqual( instanceOf( arr.data, Array ), true, 'returns expected value' ); - t.deepEqual( arr.data, expected, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - t.strictEqual( arr.iget( arr.length+10 ), 0, 'returns expected value' ); - arr.iset( arr.length+10, 1 ); - t.strictEqual( arr.iget( arr.length+10 ), 1, 'returns expected value' ); - - t.strictEqual( arr.get( 2, 2, 2 ), 0, 'returns expected value' ); - arr.set( 2, 2, 2, 3 ); - t.strictEqual( arr.get( 0, 0, 0 ), 3, 'returns expected value' ); - t.strictEqual( arr.get( 2, 2, 2 ), 3, 'returns expected value' ); - - t.end(); -});