From 1418bcf72fd7cdfd7443e550424ec8f8206c2760 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 18 Apr 2026 10:55:41 +0000 Subject: [PATCH 01/14] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index bff6014..acadcde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/package.json b/package.json index 9c2bd01..f03942a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides": "^0.2.3", "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 241688899be761e393f9652b76e67fc1d514a923 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 18 Apr 2026 10:56:34 +0000 Subject: [PATCH 02/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .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 | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 115 - benchmark/benchmark.ndims.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 35 - docs/types/test.ts | 82 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 44 - lib/main.js | 152 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 644 --- 44 files changed, 4867 insertions(+), 4872 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.ndims.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 (95%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +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 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# 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 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +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 - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3e13666..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/base/tile) 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 ad10d2a..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/base/tile) 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 7244d1e..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: '52 16 * * 2' - - # 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +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 notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # 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 + + ```
@@ -160,7 +151,7 @@ console.log( ndarray2array( out ) ); ## 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]. @@ -223,7 +214,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-tile/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/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 833fada..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float64Array = require( '@stdlib/array-float64' ); -var ndarrayBase = require( '@stdlib/ndarray-base-ctor' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::ctor=base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::ctor=non-base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.ndims.js b/benchmark/benchmark.ndims.js deleted file mode 100644 index a4e711b..0000000 --- a/benchmark/benchmark.ndims.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 array = require( '@stdlib/ndarray-array' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} ndims - number of output dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( ndims ) { - var reps; - var x; - var i; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - reps = []; - for ( i = 0; i < ndims; i++ ) { - reps.push( 1 ); - } - reps[ ndims-1 ] = 2; - if ( ndims >= 2 ) { - reps[ ndims-2 ] = 2; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( x, reps ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 2; - max = 10; - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( format( '%s::ctor=non-base,ndims=%d,order=row-major', pkg, i ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a7de45a..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/base/tile" -%% click B href "https://github.com/stdlib-js/ndarray-base-tile/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-tile/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-tile/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-tile/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-tile/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/tile -[production-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-tile/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 1951865..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import tile from '../docs/types/index'; -export = tile; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index ee4d045..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var E=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var z=E(function(Q,k){"use strict";var S=require("@stdlib/ndarray-base-ctor"),M=require("@stdlib/ndarray-base-assign"),R=require("@stdlib/ndarray-base-buffer"),T=require("@stdlib/ndarray-base-numel"),O=require("@stdlib/ndarray-base-shape2strides"),A=require("@stdlib/ndarray-base-strides2order"),B=require("@stdlib/ndarray-base-shape"),C=require("@stdlib/ndarray-base-strides"),F=require("@stdlib/ndarray-base-offset"),G=require("@stdlib/ndarray-base-order"),H=require("@stdlib/ndarray-base-dtype"),I=require("@stdlib/ndarray-base-data-buffer"),w=require("@stdlib/array-base-zeros"),J=require("@stdlib/string-format");function K(r,e){var u,a,g,o,v,d,h,c,j,y,f,b,D,N,m,t,l,q,p,i,n,s;if(g=B(r,!1),b=C(r,!1),u=H(r),t=e.length,m=g.length,t0?(c=T(o),d=O(o,a)):(c=1,d=[0]),h=R(u,c),j=new r.constructor(u,h,o,d,0,a),D=S(u,I(r),v,f,F(r),a),N=S(u,h,v,O(v,a),0,a),M([D,N]),j}k.exports=K});var L=z();module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 006ec9e..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) 2026 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 ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar assign = require( '@stdlib/ndarray-base-assign' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar getShape = require( '@stdlib/ndarray-base-shape' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 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* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* @module @stdlib/ndarray-base-tile\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n* var tile = require( '@stdlib/ndarray-base-tile' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\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,EAAU,QAAS,2BAA4B,EAC/CC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAW,QAAS,4BAA6B,EACjDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAAMC,EAAGC,EAAO,CACxB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EACAC,EAQJ,GANAlB,EAAMb,EAAUS,EAAG,EAAM,EACzBa,EAAKrB,EAAYQ,EAAG,EAAM,EAC1BE,EAAQP,EAAUK,CAAE,EACpBiB,EAAIhB,EAAK,OACTe,EAAIZ,EAAI,OAEHa,EAAID,EACR,MAAM,IAAI,WAAYlB,EAAQ,0LAA2LkB,EAAGC,CAAE,CAAE,EAkBjO,IAfAN,EAAKM,EAAID,EAETE,EAAI5B,EAAeuB,CAAG,EACjBK,IAAM,GAAKA,IAAM,EAErBf,EAAQT,EAAUM,CAAE,EACTkB,IAAM,EACjBf,EAAQ,YAERA,EAAQ,eAGTG,EAAMT,EAAO,EAAEoB,CAAE,EACjBL,EAAKf,EAAO,EAAEoB,CAAE,EAChBZ,EAAMR,EAAOoB,CAAE,EACT,EAAI,EAAG,EAAIA,EAAG,IACnBI,EAAI,EAAIV,EACRW,EAAI,EAAI,EACRH,EAAME,EAAI,EAAM,EAAIjB,EAAKiB,CAAE,EAC3BD,EAAMC,EAAI,EAAM,EAAIR,EAAIQ,CAAE,EAC1BhB,EAAK,CAAE,EAAIJ,EAAM,CAAE,EAAIkB,EAClBhB,IAAU,aACdG,EAAKgB,CAAE,EAAIrB,EAAM,CAAE,EACnBK,EAAKgB,EAAE,CAAE,EAAIH,EACbP,EAAIU,EAAE,CAAE,EAAIF,IAEZd,EAAKgB,CAAE,EAAIH,EACXb,EAAKgB,EAAE,CAAE,EAAIrB,EAAM,CAAE,EACrBW,EAAIU,CAAE,EAAIF,GAGZ,OAAKH,EAAI,GACRR,EAAMrB,EAAOiB,CAAI,EACjBE,EAAMlB,EAAegB,EAAKF,CAAM,IAEhCM,EAAM,EACNF,EAAM,CAAE,CAAE,GAGXC,EAAMrB,EAAQe,EAAOO,CAAI,EACzBC,EAAM,IAAIV,EAAE,YAAaE,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,CAAM,EAGxDW,EAAK7B,EAASiB,EAAON,EAASI,CAAE,EAAGM,EAAKM,EAAInB,EAAWO,CAAE,EAAGG,CAAM,EAClEY,EAAK9B,EAASiB,EAAOM,EAAKF,EAAKjB,EAAeiB,EAAKH,CAAM,EAAG,EAAGA,CAAM,EAGrEjB,EAAQ,CAAE4B,EAAIC,CAAG,CAAE,EAEZL,CACR,CAKA1B,EAAO,QAAUe,ICjHjB,IAAIwB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "ndarray", "assign", "buffer", "numel", "shape2strides", "strides2order", "getShape", "getStrides", "getOffset", "getOrder", "getDType", "getData", "zeros", "format", "tile", "x", "reps", "dtype", "order", "shx", "sho", "shi", "sto", "buf", "len", "out", "Ds", "si", "sx", "v1", "v2", "M", "N", "o", "s", "t", "j", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 339b8f8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, reps ) - Returns an ndarray created by repeating the elements of an input ndarray - a specified number of times along each dimension. - - The number of repetitions must have at least as many elements as the number - of input dimensions. When the number of repetitions exceeds the number of - input dimensions, the input array is treated as if singleton dimensions - were prepended. - - The function always copies data to a new ndarray. - - Parameters - ---------- - x: ndarray - Input array. - - reps: ArrayLikeObject - Number of repetitions along each dimension. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 1, 2 ], [ 3, 4 ] ] - > var o = {{alias}}( x, [ 2, 2 ] ) - [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a7281a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 space-in-parens */ - -/// - -import zeros = require( '@stdlib/ndarray-zeros' ); -import tile = require( './index' ); - - -// TESTS // - -// The function returns an ndarray having the same type as the input ndarray... -{ - tile( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), [ 2, 2 ] ); // $ExpectType float64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), [ 2, 2 ] ); // $ExpectType float32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), [ 2, 2 ] ); // $ExpectType complex128ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), [ 2, 2 ] ); // $ExpectType complex64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), [ 2, 2 ] ); // $ExpectType int32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), [ 2, 2 ] ); // $ExpectType int16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), [ 2, 2 ] ); // $ExpectType int8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), [ 2, 2 ] ); // $ExpectType uint32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), [ 2, 2 ] ); // $ExpectType uint16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), [ 2, 2 ] ); // $ExpectType uint8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), [ 2, 2 ] ); // $ExpectType uint8cndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), [ 2, 2 ] ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a first argument which is an ndarray... -{ - tile( '5', [ 2, 2, 2 ] ); // $ExpectError - tile( 5, [ 2, 2, 2 ] ); // $ExpectError - tile( true, [ 2, 2, 2 ] ); // $ExpectError - tile( false, [ 2, 2, 2 ] ); // $ExpectError - tile( null, [ 2, 2, 2 ] ); // $ExpectError - tile( {}, [ 2, 2, 2 ] ); // $ExpectError - tile( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError - tile( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile( x, '5' ); // $ExpectError - tile( x, 5 ); // $ExpectError - tile( x, true ); // $ExpectError - tile( x, false ); // $ExpectError - tile( x, null ); // $ExpectError - tile( x, {} ); // $ExpectError - tile( x, [ '5' ] ); // $ExpectError - tile( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile(); // $ExpectError - tile( x ); // $ExpectError - tile( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 9f5a156..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var tile = require( './../lib' ); - -// Create a 2x2 array: -var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -console.log( ndarray2array( x ) ); - -// Tile the array to 4x4: -var out = tile( x, [ 2, 2 ] ); -console.log( ndarray2array( out ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6b86cbd..3398c69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fb9dfa1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbbd597 --- /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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e446fd8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* @module @stdlib/ndarray-base-tile -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* var tile = require( '@stdlib/ndarray-base-tile' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ - -// 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 acadcde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var assign = require( '@stdlib/ndarray-base-assign' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param {ndarray} x - input array -* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension -* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions -* @returns {ndarray} output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -function tile( x, reps ) { - var dtype; - var order; - var shx; - var sho; - var shi; - var sto; - var buf; - var len; - var out; - var Ds; - var si; - var sx; - var v1; - var v2; - var M; - var N; - var o; - var s; - var t; - var i; - var j; - var k; - - shx = getShape( x, false ); - sx = getStrides( x, false ); - dtype = getDType( x ); - N = reps.length; - M = shx.length; - - if ( N < M ) { - throw new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) ); - } - // Compute the implicit left-padding amount for the input shape: - Ds = N - M; - - o = strides2order( sx ); - if ( o === 0 || o === 3 ) { - // Fallback to stated layout when unable to infer the underlying physical layout: - order = getOrder( x ); - } else if ( o === 1 ) { - order = 'row-major'; - } else { - order = 'column-major'; - } - // Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy... - shi = zeros( 2*N ); - si = zeros( 2*N ); - sho = zeros( N ); - for ( i = 0; i < N; i++ ) { - j = i - Ds; - k = 2 * i; - s = ( j < 0 ) ? 1 : shx[ j ]; - t = ( j < 0 ) ? 0 : sx[ j ]; - sho[ i ] = reps[ i ] * s; - if ( order === 'row-major' ) { - shi[ k ] = reps[ i ]; - shi[ k+1 ] = s; - si[ k+1 ] = t; - } else { // order === 'column-major' - shi[ k ] = s; - shi[ k+1 ] = reps[ i ]; - si[ k ] = t; - } - } - if ( N > 0 ) { - len = numel( sho ); - sto = shape2strides( sho, order ); - } else { - len = 1; - sto = [ 0 ]; - } - // Allocate an output array: - buf = buffer( dtype, len ); - out = new x.constructor( dtype, buf, sho, sto, 0, order ); - - // Create a "broadcasted" input 2N-D view over the data buffers: - v1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order ); - v2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order ); - - // Copy the elements to the output array: - assign( [ v1, v2 ] ); - - return out; -} - - -// EXPORTS // - -module.exports = tile; diff --git a/package.json b/package.json index f03942a..f26f289 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Construct a new ndarray by repeating the elements of an input ndarray a specified number of times along each dimension.", "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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/ndarray-base-assign": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "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.3" - }, - "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..329f9b2 --- /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 7702356..0000000 --- a/test/test.js +++ /dev/null @@ -1,644 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var base = require( '@stdlib/ndarray-base-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var tile = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof tile, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tiles an input array (row-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (row-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if the number of repetitions is less than the number of input dimensions', function test( t ) { - var values; - var x; - var i; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - - values = [ - [], - [ 2 ], - [ 2, 2 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - tile( x, value ); - }; - } -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ] ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2 ], [ 2, 1 ], [ 1, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1 ], [ 2 ] ] ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3 ], [ 3 ], [ 1 ], 0, 'row-major' ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ 1, 2, 3 ] ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function infers the output layout from the input strides (non-monotonic strides)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], [ 2, 3, 2 ], [ 2, 4, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 5, 6, 5, 6 ], - [ 9, 10, 9, 10 ] - ], - [ - [ 3, 4, 3, 4 ], - [ 7, 8, 7, 8 ], - [ 11, 12, 11, 12 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (base)', function test( t ) { - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (non-base)', function test( t ) { - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); From b8846f6dd6c24b238ba91bdd4e3404020847b416 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:26:12 +0000 Subject: [PATCH 03/14] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index bff6014..acadcde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/package.json b/package.json index 9c2bd01..f03942a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides": "^0.2.3", "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 4b44a9eb85c55a2286a1aacf000078951f7f164c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:28:32 +0000 Subject: [PATCH 04/14] Remove files --- index.d.ts | 52 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4899 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 3398c69..0000000 --- a/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ArrayLike } from '@stdlib/types/array'; -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param x - input array -* @param reps - number of repetitions along each dimension -* @returns output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -declare function tile( x: T, reps: ArrayLike ): T; - - -// EXPORTS // - -export = tile; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fb9dfa1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbbd597..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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 329f9b2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 40c0528c5a3fdd98db603fe2ec990a696447a785 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:29:01 +0000 Subject: [PATCH 05/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .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 | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 115 - benchmark/benchmark.ndims.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 35 - docs/types/test.ts | 82 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 44 - lib/main.js | 152 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 644 --- 45 files changed, 4867 insertions(+), 4891 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.ndims.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 (95%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +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 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# 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 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +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 - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3e7d02e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-21T03:24:03.720Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3e13666..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/base/tile) 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 ad10d2a..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/base/tile) 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 7244d1e..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: '52 16 * * 2' - - # 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +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 notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # 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 + + ```
@@ -160,7 +151,7 @@ console.log( ndarray2array( out ) ); ## 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]. @@ -223,7 +214,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-tile/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/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 833fada..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float64Array = require( '@stdlib/array-float64' ); -var ndarrayBase = require( '@stdlib/ndarray-base-ctor' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::ctor=base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::ctor=non-base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.ndims.js b/benchmark/benchmark.ndims.js deleted file mode 100644 index a4e711b..0000000 --- a/benchmark/benchmark.ndims.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 array = require( '@stdlib/ndarray-array' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} ndims - number of output dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( ndims ) { - var reps; - var x; - var i; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - reps = []; - for ( i = 0; i < ndims; i++ ) { - reps.push( 1 ); - } - reps[ ndims-1 ] = 2; - if ( ndims >= 2 ) { - reps[ ndims-2 ] = 2; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( x, reps ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 2; - max = 10; - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( format( '%s::ctor=non-base,ndims=%d,order=row-major', pkg, i ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a7de45a..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/base/tile" -%% click B href "https://github.com/stdlib-js/ndarray-base-tile/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-tile/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-tile/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-tile/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-tile/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/tile -[production-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-tile/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 1951865..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import tile from '../docs/types/index'; -export = tile; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index ee4d045..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var E=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var z=E(function(Q,k){"use strict";var S=require("@stdlib/ndarray-base-ctor"),M=require("@stdlib/ndarray-base-assign"),R=require("@stdlib/ndarray-base-buffer"),T=require("@stdlib/ndarray-base-numel"),O=require("@stdlib/ndarray-base-shape2strides"),A=require("@stdlib/ndarray-base-strides2order"),B=require("@stdlib/ndarray-base-shape"),C=require("@stdlib/ndarray-base-strides"),F=require("@stdlib/ndarray-base-offset"),G=require("@stdlib/ndarray-base-order"),H=require("@stdlib/ndarray-base-dtype"),I=require("@stdlib/ndarray-base-data-buffer"),w=require("@stdlib/array-base-zeros"),J=require("@stdlib/string-format");function K(r,e){var u,a,g,o,v,d,h,c,j,y,f,b,D,N,m,t,l,q,p,i,n,s;if(g=B(r,!1),b=C(r,!1),u=H(r),t=e.length,m=g.length,t0?(c=T(o),d=O(o,a)):(c=1,d=[0]),h=R(u,c),j=new r.constructor(u,h,o,d,0,a),D=S(u,I(r),v,f,F(r),a),N=S(u,h,v,O(v,a),0,a),M([D,N]),j}k.exports=K});var L=z();module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 006ec9e..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) 2026 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 ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar assign = require( '@stdlib/ndarray-base-assign' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar getShape = require( '@stdlib/ndarray-base-shape' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 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* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* @module @stdlib/ndarray-base-tile\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n* var tile = require( '@stdlib/ndarray-base-tile' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\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,EAAU,QAAS,2BAA4B,EAC/CC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAW,QAAS,4BAA6B,EACjDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAAMC,EAAGC,EAAO,CACxB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EACAC,EAQJ,GANAlB,EAAMb,EAAUS,EAAG,EAAM,EACzBa,EAAKrB,EAAYQ,EAAG,EAAM,EAC1BE,EAAQP,EAAUK,CAAE,EACpBiB,EAAIhB,EAAK,OACTe,EAAIZ,EAAI,OAEHa,EAAID,EACR,MAAM,IAAI,WAAYlB,EAAQ,0LAA2LkB,EAAGC,CAAE,CAAE,EAkBjO,IAfAN,EAAKM,EAAID,EAETE,EAAI5B,EAAeuB,CAAG,EACjBK,IAAM,GAAKA,IAAM,EAErBf,EAAQT,EAAUM,CAAE,EACTkB,IAAM,EACjBf,EAAQ,YAERA,EAAQ,eAGTG,EAAMT,EAAO,EAAEoB,CAAE,EACjBL,EAAKf,EAAO,EAAEoB,CAAE,EAChBZ,EAAMR,EAAOoB,CAAE,EACT,EAAI,EAAG,EAAIA,EAAG,IACnBI,EAAI,EAAIV,EACRW,EAAI,EAAI,EACRH,EAAME,EAAI,EAAM,EAAIjB,EAAKiB,CAAE,EAC3BD,EAAMC,EAAI,EAAM,EAAIR,EAAIQ,CAAE,EAC1BhB,EAAK,CAAE,EAAIJ,EAAM,CAAE,EAAIkB,EAClBhB,IAAU,aACdG,EAAKgB,CAAE,EAAIrB,EAAM,CAAE,EACnBK,EAAKgB,EAAE,CAAE,EAAIH,EACbP,EAAIU,EAAE,CAAE,EAAIF,IAEZd,EAAKgB,CAAE,EAAIH,EACXb,EAAKgB,EAAE,CAAE,EAAIrB,EAAM,CAAE,EACrBW,EAAIU,CAAE,EAAIF,GAGZ,OAAKH,EAAI,GACRR,EAAMrB,EAAOiB,CAAI,EACjBE,EAAMlB,EAAegB,EAAKF,CAAM,IAEhCM,EAAM,EACNF,EAAM,CAAE,CAAE,GAGXC,EAAMrB,EAAQe,EAAOO,CAAI,EACzBC,EAAM,IAAIV,EAAE,YAAaE,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,CAAM,EAGxDW,EAAK7B,EAASiB,EAAON,EAASI,CAAE,EAAGM,EAAKM,EAAInB,EAAWO,CAAE,EAAGG,CAAM,EAClEY,EAAK9B,EAASiB,EAAOM,EAAKF,EAAKjB,EAAeiB,EAAKH,CAAM,EAAG,EAAGA,CAAM,EAGrEjB,EAAQ,CAAE4B,EAAIC,CAAG,CAAE,EAEZL,CACR,CAKA1B,EAAO,QAAUe,ICjHjB,IAAIwB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "ndarray", "assign", "buffer", "numel", "shape2strides", "strides2order", "getShape", "getStrides", "getOffset", "getOrder", "getDType", "getData", "zeros", "format", "tile", "x", "reps", "dtype", "order", "shx", "sho", "shi", "sto", "buf", "len", "out", "Ds", "si", "sx", "v1", "v2", "M", "N", "o", "s", "t", "j", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 339b8f8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, reps ) - Returns an ndarray created by repeating the elements of an input ndarray - a specified number of times along each dimension. - - The number of repetitions must have at least as many elements as the number - of input dimensions. When the number of repetitions exceeds the number of - input dimensions, the input array is treated as if singleton dimensions - were prepended. - - The function always copies data to a new ndarray. - - Parameters - ---------- - x: ndarray - Input array. - - reps: ArrayLikeObject - Number of repetitions along each dimension. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 1, 2 ], [ 3, 4 ] ] - > var o = {{alias}}( x, [ 2, 2 ] ) - [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a7281a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 space-in-parens */ - -/// - -import zeros = require( '@stdlib/ndarray-zeros' ); -import tile = require( './index' ); - - -// TESTS // - -// The function returns an ndarray having the same type as the input ndarray... -{ - tile( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), [ 2, 2 ] ); // $ExpectType float64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), [ 2, 2 ] ); // $ExpectType float32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), [ 2, 2 ] ); // $ExpectType complex128ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), [ 2, 2 ] ); // $ExpectType complex64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), [ 2, 2 ] ); // $ExpectType int32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), [ 2, 2 ] ); // $ExpectType int16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), [ 2, 2 ] ); // $ExpectType int8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), [ 2, 2 ] ); // $ExpectType uint32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), [ 2, 2 ] ); // $ExpectType uint16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), [ 2, 2 ] ); // $ExpectType uint8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), [ 2, 2 ] ); // $ExpectType uint8cndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), [ 2, 2 ] ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a first argument which is an ndarray... -{ - tile( '5', [ 2, 2, 2 ] ); // $ExpectError - tile( 5, [ 2, 2, 2 ] ); // $ExpectError - tile( true, [ 2, 2, 2 ] ); // $ExpectError - tile( false, [ 2, 2, 2 ] ); // $ExpectError - tile( null, [ 2, 2, 2 ] ); // $ExpectError - tile( {}, [ 2, 2, 2 ] ); // $ExpectError - tile( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError - tile( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile( x, '5' ); // $ExpectError - tile( x, 5 ); // $ExpectError - tile( x, true ); // $ExpectError - tile( x, false ); // $ExpectError - tile( x, null ); // $ExpectError - tile( x, {} ); // $ExpectError - tile( x, [ '5' ] ); // $ExpectError - tile( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile(); // $ExpectError - tile( x ); // $ExpectError - tile( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 9f5a156..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var tile = require( './../lib' ); - -// Create a 2x2 array: -var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -console.log( ndarray2array( x ) ); - -// Tile the array to 4x4: -var out = tile( x, [ 2, 2 ] ); -console.log( ndarray2array( out ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6b86cbd..3398c69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fb9dfa1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbbd597 --- /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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e446fd8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* @module @stdlib/ndarray-base-tile -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* var tile = require( '@stdlib/ndarray-base-tile' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ - -// 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 acadcde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var assign = require( '@stdlib/ndarray-base-assign' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param {ndarray} x - input array -* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension -* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions -* @returns {ndarray} output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -function tile( x, reps ) { - var dtype; - var order; - var shx; - var sho; - var shi; - var sto; - var buf; - var len; - var out; - var Ds; - var si; - var sx; - var v1; - var v2; - var M; - var N; - var o; - var s; - var t; - var i; - var j; - var k; - - shx = getShape( x, false ); - sx = getStrides( x, false ); - dtype = getDType( x ); - N = reps.length; - M = shx.length; - - if ( N < M ) { - throw new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) ); - } - // Compute the implicit left-padding amount for the input shape: - Ds = N - M; - - o = strides2order( sx ); - if ( o === 0 || o === 3 ) { - // Fallback to stated layout when unable to infer the underlying physical layout: - order = getOrder( x ); - } else if ( o === 1 ) { - order = 'row-major'; - } else { - order = 'column-major'; - } - // Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy... - shi = zeros( 2*N ); - si = zeros( 2*N ); - sho = zeros( N ); - for ( i = 0; i < N; i++ ) { - j = i - Ds; - k = 2 * i; - s = ( j < 0 ) ? 1 : shx[ j ]; - t = ( j < 0 ) ? 0 : sx[ j ]; - sho[ i ] = reps[ i ] * s; - if ( order === 'row-major' ) { - shi[ k ] = reps[ i ]; - shi[ k+1 ] = s; - si[ k+1 ] = t; - } else { // order === 'column-major' - shi[ k ] = s; - shi[ k+1 ] = reps[ i ]; - si[ k ] = t; - } - } - if ( N > 0 ) { - len = numel( sho ); - sto = shape2strides( sho, order ); - } else { - len = 1; - sto = [ 0 ]; - } - // Allocate an output array: - buf = buffer( dtype, len ); - out = new x.constructor( dtype, buf, sho, sto, 0, order ); - - // Create a "broadcasted" input 2N-D view over the data buffers: - v1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order ); - v2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order ); - - // Copy the elements to the output array: - assign( [ v1, v2 ] ); - - return out; -} - - -// EXPORTS // - -module.exports = tile; diff --git a/package.json b/package.json index f03942a..f26f289 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Construct a new ndarray by repeating the elements of an input ndarray a specified number of times along each dimension.", "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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/ndarray-base-assign": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "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.3" - }, - "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..329f9b2 --- /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 7702356..0000000 --- a/test/test.js +++ /dev/null @@ -1,644 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var base = require( '@stdlib/ndarray-base-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var tile = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof tile, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tiles an input array (row-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (row-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if the number of repetitions is less than the number of input dimensions', function test( t ) { - var values; - var x; - var i; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - - values = [ - [], - [ 2 ], - [ 2, 2 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - tile( x, value ); - }; - } -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ] ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2 ], [ 2, 1 ], [ 1, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1 ], [ 2 ] ] ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3 ], [ 3 ], [ 1 ], 0, 'row-major' ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ 1, 2, 3 ] ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function infers the output layout from the input strides (non-monotonic strides)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], [ 2, 3, 2 ], [ 2, 4, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 5, 6, 5, 6 ], - [ 9, 10, 9, 10 ] - ], - [ - [ 3, 4, 3, 4 ], - [ 7, 8, 7, 8 ], - [ 11, 12, 11, 12 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (base)', function test( t ) { - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (non-base)', function test( t ) { - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); From f691e198cc7ee93755b1962125559b0219d6530b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 01:56:29 +0000 Subject: [PATCH 06/14] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index bff6014..acadcde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/package.json b/package.json index 140a458..e7ff721 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides": "^0.2.3", "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 3d9da36659cad1cd55ea08010cef708c78c07e60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 02:08:10 +0000 Subject: [PATCH 07/14] Remove files --- index.d.ts | 52 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4899 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 3398c69..0000000 --- a/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ArrayLike } from '@stdlib/types/array'; -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param x - input array -* @param reps - number of repetitions along each dimension -* @returns output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -declare function tile( x: T, reps: ArrayLike ): T; - - -// EXPORTS // - -export = tile; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fb9dfa1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbbd597..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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 329f9b2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9ccd0460acc1f80012fce6de830552f44c818dea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 02:08:53 +0000 Subject: [PATCH 08/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .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 | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 115 - benchmark/benchmark.ndims.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 35 - docs/types/test.ts | 82 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 44 - lib/main.js | 152 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 644 --- 44 files changed, 4867 insertions(+), 4892 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.ndims.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 (95%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +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 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# 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 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +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 - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3e13666..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/base/tile) 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 ad10d2a..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/base/tile) 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 7244d1e..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: '52 16 * * 2' - - # 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +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 notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # 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 + + ```
@@ -160,7 +151,7 @@ console.log( ndarray2array( out ) ); ## 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]. @@ -223,7 +214,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-tile/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/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 833fada..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float64Array = require( '@stdlib/array-float64' ); -var ndarrayBase = require( '@stdlib/ndarray-base-ctor' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::ctor=base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::ctor=non-base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.ndims.js b/benchmark/benchmark.ndims.js deleted file mode 100644 index a4e711b..0000000 --- a/benchmark/benchmark.ndims.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 array = require( '@stdlib/ndarray-array' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} ndims - number of output dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( ndims ) { - var reps; - var x; - var i; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - reps = []; - for ( i = 0; i < ndims; i++ ) { - reps.push( 1 ); - } - reps[ ndims-1 ] = 2; - if ( ndims >= 2 ) { - reps[ ndims-2 ] = 2; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( x, reps ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 2; - max = 10; - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( format( '%s::ctor=non-base,ndims=%d,order=row-major', pkg, i ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a7de45a..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/base/tile" -%% click B href "https://github.com/stdlib-js/ndarray-base-tile/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-tile/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-tile/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-tile/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-tile/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/tile -[production-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-tile/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 1951865..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import tile from '../docs/types/index'; -export = tile; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 04118a2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var E=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(s){throw r=0,s}}};var z=E(function(Q,k){"use strict";var S=require("@stdlib/ndarray-base-ctor"),M=require("@stdlib/ndarray-base-assign"),R=require("@stdlib/ndarray-base-buffer"),T=require("@stdlib/ndarray-base-numel"),O=require("@stdlib/ndarray-base-shape2strides"),A=require("@stdlib/ndarray-base-strides2order"),B=require("@stdlib/ndarray-base-shape"),C=require("@stdlib/ndarray-base-strides"),F=require("@stdlib/ndarray-base-offset"),G=require("@stdlib/ndarray-base-order"),H=require("@stdlib/ndarray-base-dtype"),I=require("@stdlib/ndarray-base-data-buffer"),w=require("@stdlib/array-base-zeros"),J=require("@stdlib/string-format");function K(e,r){var s,a,g,o,v,d,h,c,j,y,f,b,D,N,m,t,l,q,p,i,n,u;if(g=B(e,!1),b=C(e,!1),s=H(e),t=r.length,m=g.length,t0?(c=T(o),d=O(o,a)):(c=1,d=[0]),h=R(s,c),j=new e.constructor(s,h,o,d,0,a),D=S(s,I(e),v,f,F(e),a),N=S(s,h,v,O(v,a),0,a),M([D,N]),j}k.exports=K});var L=z();module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 59f9588..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) 2026 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 ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar assign = require( '@stdlib/ndarray-base-assign' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar getShape = require( '@stdlib/ndarray-base-shape' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 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* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* @module @stdlib/ndarray-base-tile\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n* var tile = require( '@stdlib/ndarray-base-tile' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,2BAA4B,EAC/CC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAW,QAAS,4BAA6B,EACjDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAAMC,EAAGC,EAAO,CACxB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EACAC,EAQJ,GANAlB,EAAMb,EAAUS,EAAG,EAAM,EACzBa,EAAKrB,EAAYQ,EAAG,EAAM,EAC1BE,EAAQP,EAAUK,CAAE,EACpBiB,EAAIhB,EAAK,OACTe,EAAIZ,EAAI,OAEHa,EAAID,EACR,MAAM,IAAI,WAAYlB,EAAQ,0LAA2LkB,EAAGC,CAAE,CAAE,EAkBjO,IAfAN,EAAKM,EAAID,EAETE,EAAI5B,EAAeuB,CAAG,EACjBK,IAAM,GAAKA,IAAM,EAErBf,EAAQT,EAAUM,CAAE,EACTkB,IAAM,EACjBf,EAAQ,YAERA,EAAQ,eAGTG,EAAMT,EAAO,EAAEoB,CAAE,EACjBL,EAAKf,EAAO,EAAEoB,CAAE,EAChBZ,EAAMR,EAAOoB,CAAE,EACT,EAAI,EAAG,EAAIA,EAAG,IACnBI,EAAI,EAAIV,EACRW,EAAI,EAAI,EACRH,EAAME,EAAI,EAAM,EAAIjB,EAAKiB,CAAE,EAC3BD,EAAMC,EAAI,EAAM,EAAIR,EAAIQ,CAAE,EAC1BhB,EAAK,CAAE,EAAIJ,EAAM,CAAE,EAAIkB,EAClBhB,IAAU,aACdG,EAAKgB,CAAE,EAAIrB,EAAM,CAAE,EACnBK,EAAKgB,EAAE,CAAE,EAAIH,EACbP,EAAIU,EAAE,CAAE,EAAIF,IAEZd,EAAKgB,CAAE,EAAIH,EACXb,EAAKgB,EAAE,CAAE,EAAIrB,EAAM,CAAE,EACrBW,EAAIU,CAAE,EAAIF,GAGZ,OAAKH,EAAI,GACRR,EAAMrB,EAAOiB,CAAI,EACjBE,EAAMlB,EAAegB,EAAKF,CAAM,IAEhCM,EAAM,EACNF,EAAM,CAAE,CAAE,GAGXC,EAAMrB,EAAQe,EAAOO,CAAI,EACzBC,EAAM,IAAIV,EAAE,YAAaE,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,CAAM,EAGxDW,EAAK7B,EAASiB,EAAON,EAASI,CAAE,EAAGM,EAAKM,EAAInB,EAAWO,CAAE,EAAGG,CAAM,EAClEY,EAAK9B,EAASiB,EAAOM,EAAKF,EAAKjB,EAAeiB,EAAKH,CAAM,EAAG,EAAGA,CAAM,EAGrEjB,EAAQ,CAAE4B,EAAIC,CAAG,CAAE,EAEZL,CACR,CAKA1B,EAAO,QAAUe,ICjHjB,IAAIwB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "ndarray", "assign", "buffer", "numel", "shape2strides", "strides2order", "getShape", "getStrides", "getOffset", "getOrder", "getDType", "getData", "zeros", "format", "tile", "x", "reps", "dtype", "order", "shx", "sho", "shi", "sto", "buf", "len", "out", "Ds", "si", "sx", "v1", "v2", "M", "N", "o", "s", "t", "j", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 339b8f8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, reps ) - Returns an ndarray created by repeating the elements of an input ndarray - a specified number of times along each dimension. - - The number of repetitions must have at least as many elements as the number - of input dimensions. When the number of repetitions exceeds the number of - input dimensions, the input array is treated as if singleton dimensions - were prepended. - - The function always copies data to a new ndarray. - - Parameters - ---------- - x: ndarray - Input array. - - reps: ArrayLikeObject - Number of repetitions along each dimension. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 1, 2 ], [ 3, 4 ] ] - > var o = {{alias}}( x, [ 2, 2 ] ) - [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a7281a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 space-in-parens */ - -/// - -import zeros = require( '@stdlib/ndarray-zeros' ); -import tile = require( './index' ); - - -// TESTS // - -// The function returns an ndarray having the same type as the input ndarray... -{ - tile( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), [ 2, 2 ] ); // $ExpectType float64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), [ 2, 2 ] ); // $ExpectType float32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), [ 2, 2 ] ); // $ExpectType complex128ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), [ 2, 2 ] ); // $ExpectType complex64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), [ 2, 2 ] ); // $ExpectType int32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), [ 2, 2 ] ); // $ExpectType int16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), [ 2, 2 ] ); // $ExpectType int8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), [ 2, 2 ] ); // $ExpectType uint32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), [ 2, 2 ] ); // $ExpectType uint16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), [ 2, 2 ] ); // $ExpectType uint8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), [ 2, 2 ] ); // $ExpectType uint8cndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), [ 2, 2 ] ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a first argument which is an ndarray... -{ - tile( '5', [ 2, 2, 2 ] ); // $ExpectError - tile( 5, [ 2, 2, 2 ] ); // $ExpectError - tile( true, [ 2, 2, 2 ] ); // $ExpectError - tile( false, [ 2, 2, 2 ] ); // $ExpectError - tile( null, [ 2, 2, 2 ] ); // $ExpectError - tile( {}, [ 2, 2, 2 ] ); // $ExpectError - tile( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError - tile( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile( x, '5' ); // $ExpectError - tile( x, 5 ); // $ExpectError - tile( x, true ); // $ExpectError - tile( x, false ); // $ExpectError - tile( x, null ); // $ExpectError - tile( x, {} ); // $ExpectError - tile( x, [ '5' ] ); // $ExpectError - tile( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile(); // $ExpectError - tile( x ); // $ExpectError - tile( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 9f5a156..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var tile = require( './../lib' ); - -// Create a 2x2 array: -var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -console.log( ndarray2array( x ) ); - -// Tile the array to 4x4: -var out = tile( x, [ 2, 2 ] ); -console.log( ndarray2array( out ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b7c32af..593dd28 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7544334 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 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/ndarray-base-ctor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,f){var g,v,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),g=j(b),(B=f.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,v=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,v)):(N=1,y=[0]),w=r(g,N),z=new b.constructor(g,w,u,y,0,v),k=s(g,l(b),x,R,a(b),v),q=s(g,w,x,d(x,v),0,v),e([k,q]),z}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..47a6c8e --- /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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;4uCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e446fd8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* @module @stdlib/ndarray-base-tile -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* var tile = require( '@stdlib/ndarray-base-tile' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ - -// 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 acadcde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var assign = require( '@stdlib/ndarray-base-assign' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param {ndarray} x - input array -* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension -* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions -* @returns {ndarray} output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -function tile( x, reps ) { - var dtype; - var order; - var shx; - var sho; - var shi; - var sto; - var buf; - var len; - var out; - var Ds; - var si; - var sx; - var v1; - var v2; - var M; - var N; - var o; - var s; - var t; - var i; - var j; - var k; - - shx = getShape( x, false ); - sx = getStrides( x, false ); - dtype = getDType( x ); - N = reps.length; - M = shx.length; - - if ( N < M ) { - throw new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) ); - } - // Compute the implicit left-padding amount for the input shape: - Ds = N - M; - - o = strides2order( sx ); - if ( o === 0 || o === 3 ) { - // Fallback to stated layout when unable to infer the underlying physical layout: - order = getOrder( x ); - } else if ( o === 1 ) { - order = 'row-major'; - } else { - order = 'column-major'; - } - // Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy... - shi = zeros( 2*N ); - si = zeros( 2*N ); - sho = zeros( N ); - for ( i = 0; i < N; i++ ) { - j = i - Ds; - k = 2 * i; - s = ( j < 0 ) ? 1 : shx[ j ]; - t = ( j < 0 ) ? 0 : sx[ j ]; - sho[ i ] = reps[ i ] * s; - if ( order === 'row-major' ) { - shi[ k ] = reps[ i ]; - shi[ k+1 ] = s; - si[ k+1 ] = t; - } else { // order === 'column-major' - shi[ k ] = s; - shi[ k+1 ] = reps[ i ]; - si[ k ] = t; - } - } - if ( N > 0 ) { - len = numel( sho ); - sto = shape2strides( sho, order ); - } else { - len = 1; - sto = [ 0 ]; - } - // Allocate an output array: - buf = buffer( dtype, len ); - out = new x.constructor( dtype, buf, sho, sto, 0, order ); - - // Create a "broadcasted" input 2N-D view over the data buffers: - v1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order ); - v2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order ); - - // Copy the elements to the output array: - assign( [ v1, v2 ] ); - - return out; -} - - -// EXPORTS // - -module.exports = tile; diff --git a/package.json b/package.json index e7ff721..f26f289 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Construct a new ndarray by repeating the elements of an input ndarray a specified number of times along each dimension.", "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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/ndarray-base-assign": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "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.3" - }, - "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..4681b36 --- /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 7702356..0000000 --- a/test/test.js +++ /dev/null @@ -1,644 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var base = require( '@stdlib/ndarray-base-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var tile = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof tile, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tiles an input array (row-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (row-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if the number of repetitions is less than the number of input dimensions', function test( t ) { - var values; - var x; - var i; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - - values = [ - [], - [ 2 ], - [ 2, 2 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - tile( x, value ); - }; - } -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ] ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2 ], [ 2, 1 ], [ 1, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1 ], [ 2 ] ] ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3 ], [ 3 ], [ 1 ], 0, 'row-major' ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ 1, 2, 3 ] ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function infers the output layout from the input strides (non-monotonic strides)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], [ 2, 3, 2 ], [ 2, 4, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 5, 6, 5, 6 ], - [ 9, 10, 9, 10 ] - ], - [ - [ 3, 4, 3, 4 ], - [ 7, 8, 7, 8 ], - [ 11, 12, 11, 12 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (base)', function test( t ) { - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (non-base)', function test( t ) { - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); From 969c5936566aa995b59cf1527a5a60207ad7462c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:35:27 +0000 Subject: [PATCH 09/14] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index bff6014..acadcde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/package.json b/package.json index 140a458..e7ff721 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides": "^0.2.3", "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 146e4419bc0d9abf0ee8f32cd84df29a7298805c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:50:51 +0000 Subject: [PATCH 10/14] Remove files --- index.d.ts | 52 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4899 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 593dd28..0000000 --- a/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ArrayLike } from '@stdlib/types/array'; -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param x - input array -* @param reps - number of repetitions along each dimension -* @returns output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -declare function tile( x: T, reps: ArrayLike ): T; - - -// EXPORTS // - -export = tile; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7544334..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 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/ndarray-base-ctor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,f){var g,v,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),g=j(b),(B=f.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,v=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,v)):(N=1,y=[0]),w=r(g,N),z=new b.constructor(g,w,u,y,0,v),k=s(g,l(b),x,R,a(b),v),q=s(g,w,x,d(x,v),0,v),e([k,q]),z}export{b as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 47a6c8e..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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;4uCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4681b36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f175130684d6741b2962c782bede5b544b70fe5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:51:14 +0000 Subject: [PATCH 11/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .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 | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 115 - benchmark/benchmark.ndims.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 35 - docs/types/test.ts | 82 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 44 - lib/main.js | 152 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 644 --- 45 files changed, 4867 insertions(+), 4893 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.ndims.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 (95%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +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 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# 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 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +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 - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0cebfce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-01T03:28:33.188Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3e13666..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/base/tile) 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 ad10d2a..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/base/tile) 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 7244d1e..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: '52 16 * * 2' - - # 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +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 notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # 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 + + ```
@@ -160,7 +151,7 @@ console.log( ndarray2array( out ) ); ## 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]. @@ -223,7 +214,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-tile/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/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 833fada..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float64Array = require( '@stdlib/array-float64' ); -var ndarrayBase = require( '@stdlib/ndarray-base-ctor' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::ctor=base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::ctor=non-base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.ndims.js b/benchmark/benchmark.ndims.js deleted file mode 100644 index a4e711b..0000000 --- a/benchmark/benchmark.ndims.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 array = require( '@stdlib/ndarray-array' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} ndims - number of output dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( ndims ) { - var reps; - var x; - var i; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - reps = []; - for ( i = 0; i < ndims; i++ ) { - reps.push( 1 ); - } - reps[ ndims-1 ] = 2; - if ( ndims >= 2 ) { - reps[ ndims-2 ] = 2; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( x, reps ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 2; - max = 10; - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( format( '%s::ctor=non-base,ndims=%d,order=row-major', pkg, i ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a7de45a..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/base/tile" -%% click B href "https://github.com/stdlib-js/ndarray-base-tile/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-tile/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-tile/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-tile/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-tile/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/tile -[production-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-tile/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 1951865..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import tile from '../docs/types/index'; -export = tile; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 04118a2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var E=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(s){throw r=0,s}}};var z=E(function(Q,k){"use strict";var S=require("@stdlib/ndarray-base-ctor"),M=require("@stdlib/ndarray-base-assign"),R=require("@stdlib/ndarray-base-buffer"),T=require("@stdlib/ndarray-base-numel"),O=require("@stdlib/ndarray-base-shape2strides"),A=require("@stdlib/ndarray-base-strides2order"),B=require("@stdlib/ndarray-base-shape"),C=require("@stdlib/ndarray-base-strides"),F=require("@stdlib/ndarray-base-offset"),G=require("@stdlib/ndarray-base-order"),H=require("@stdlib/ndarray-base-dtype"),I=require("@stdlib/ndarray-base-data-buffer"),w=require("@stdlib/array-base-zeros"),J=require("@stdlib/string-format");function K(e,r){var s,a,g,o,v,d,h,c,j,y,f,b,D,N,m,t,l,q,p,i,n,u;if(g=B(e,!1),b=C(e,!1),s=H(e),t=r.length,m=g.length,t0?(c=T(o),d=O(o,a)):(c=1,d=[0]),h=R(s,c),j=new e.constructor(s,h,o,d,0,a),D=S(s,I(e),v,f,F(e),a),N=S(s,h,v,O(v,a),0,a),M([D,N]),j}k.exports=K});var L=z();module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 59f9588..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) 2026 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 ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar assign = require( '@stdlib/ndarray-base-assign' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar getShape = require( '@stdlib/ndarray-base-shape' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 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* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* @module @stdlib/ndarray-base-tile\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n* var tile = require( '@stdlib/ndarray-base-tile' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,2BAA4B,EAC/CC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAW,QAAS,4BAA6B,EACjDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAAMC,EAAGC,EAAO,CACxB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EACAC,EAQJ,GANAlB,EAAMb,EAAUS,EAAG,EAAM,EACzBa,EAAKrB,EAAYQ,EAAG,EAAM,EAC1BE,EAAQP,EAAUK,CAAE,EACpBiB,EAAIhB,EAAK,OACTe,EAAIZ,EAAI,OAEHa,EAAID,EACR,MAAM,IAAI,WAAYlB,EAAQ,0LAA2LkB,EAAGC,CAAE,CAAE,EAkBjO,IAfAN,EAAKM,EAAID,EAETE,EAAI5B,EAAeuB,CAAG,EACjBK,IAAM,GAAKA,IAAM,EAErBf,EAAQT,EAAUM,CAAE,EACTkB,IAAM,EACjBf,EAAQ,YAERA,EAAQ,eAGTG,EAAMT,EAAO,EAAEoB,CAAE,EACjBL,EAAKf,EAAO,EAAEoB,CAAE,EAChBZ,EAAMR,EAAOoB,CAAE,EACT,EAAI,EAAG,EAAIA,EAAG,IACnBI,EAAI,EAAIV,EACRW,EAAI,EAAI,EACRH,EAAME,EAAI,EAAM,EAAIjB,EAAKiB,CAAE,EAC3BD,EAAMC,EAAI,EAAM,EAAIR,EAAIQ,CAAE,EAC1BhB,EAAK,CAAE,EAAIJ,EAAM,CAAE,EAAIkB,EAClBhB,IAAU,aACdG,EAAKgB,CAAE,EAAIrB,EAAM,CAAE,EACnBK,EAAKgB,EAAE,CAAE,EAAIH,EACbP,EAAIU,EAAE,CAAE,EAAIF,IAEZd,EAAKgB,CAAE,EAAIH,EACXb,EAAKgB,EAAE,CAAE,EAAIrB,EAAM,CAAE,EACrBW,EAAIU,CAAE,EAAIF,GAGZ,OAAKH,EAAI,GACRR,EAAMrB,EAAOiB,CAAI,EACjBE,EAAMlB,EAAegB,EAAKF,CAAM,IAEhCM,EAAM,EACNF,EAAM,CAAE,CAAE,GAGXC,EAAMrB,EAAQe,EAAOO,CAAI,EACzBC,EAAM,IAAIV,EAAE,YAAaE,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,CAAM,EAGxDW,EAAK7B,EAASiB,EAAON,EAASI,CAAE,EAAGM,EAAKM,EAAInB,EAAWO,CAAE,EAAGG,CAAM,EAClEY,EAAK9B,EAASiB,EAAOM,EAAKF,EAAKjB,EAAeiB,EAAKH,CAAM,EAAG,EAAGA,CAAM,EAGrEjB,EAAQ,CAAE4B,EAAIC,CAAG,CAAE,EAEZL,CACR,CAKA1B,EAAO,QAAUe,ICjHjB,IAAIwB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "ndarray", "assign", "buffer", "numel", "shape2strides", "strides2order", "getShape", "getStrides", "getOffset", "getOrder", "getDType", "getData", "zeros", "format", "tile", "x", "reps", "dtype", "order", "shx", "sho", "shi", "sto", "buf", "len", "out", "Ds", "si", "sx", "v1", "v2", "M", "N", "o", "s", "t", "j", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 339b8f8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, reps ) - Returns an ndarray created by repeating the elements of an input ndarray - a specified number of times along each dimension. - - The number of repetitions must have at least as many elements as the number - of input dimensions. When the number of repetitions exceeds the number of - input dimensions, the input array is treated as if singleton dimensions - were prepended. - - The function always copies data to a new ndarray. - - Parameters - ---------- - x: ndarray - Input array. - - reps: ArrayLikeObject - Number of repetitions along each dimension. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 1, 2 ], [ 3, 4 ] ] - > var o = {{alias}}( x, [ 2, 2 ] ) - [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a7281a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 space-in-parens */ - -/// - -import zeros = require( '@stdlib/ndarray-zeros' ); -import tile = require( './index' ); - - -// TESTS // - -// The function returns an ndarray having the same type as the input ndarray... -{ - tile( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), [ 2, 2 ] ); // $ExpectType float64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), [ 2, 2 ] ); // $ExpectType float32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), [ 2, 2 ] ); // $ExpectType complex128ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), [ 2, 2 ] ); // $ExpectType complex64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), [ 2, 2 ] ); // $ExpectType int32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), [ 2, 2 ] ); // $ExpectType int16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), [ 2, 2 ] ); // $ExpectType int8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), [ 2, 2 ] ); // $ExpectType uint32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), [ 2, 2 ] ); // $ExpectType uint16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), [ 2, 2 ] ); // $ExpectType uint8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), [ 2, 2 ] ); // $ExpectType uint8cndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), [ 2, 2 ] ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a first argument which is an ndarray... -{ - tile( '5', [ 2, 2, 2 ] ); // $ExpectError - tile( 5, [ 2, 2, 2 ] ); // $ExpectError - tile( true, [ 2, 2, 2 ] ); // $ExpectError - tile( false, [ 2, 2, 2 ] ); // $ExpectError - tile( null, [ 2, 2, 2 ] ); // $ExpectError - tile( {}, [ 2, 2, 2 ] ); // $ExpectError - tile( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError - tile( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile( x, '5' ); // $ExpectError - tile( x, 5 ); // $ExpectError - tile( x, true ); // $ExpectError - tile( x, false ); // $ExpectError - tile( x, null ); // $ExpectError - tile( x, {} ); // $ExpectError - tile( x, [ '5' ] ); // $ExpectError - tile( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile(); // $ExpectError - tile( x ); // $ExpectError - tile( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 9f5a156..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var tile = require( './../lib' ); - -// Create a 2x2 array: -var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -console.log( ndarray2array( x ) ); - -// Tile the array to 4x4: -var out = tile( x, [ 2, 2 ] ); -console.log( ndarray2array( out ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b7c32af..593dd28 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fb9dfa1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbbd597 --- /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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e446fd8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* @module @stdlib/ndarray-base-tile -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* var tile = require( '@stdlib/ndarray-base-tile' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ - -// 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 acadcde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var assign = require( '@stdlib/ndarray-base-assign' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param {ndarray} x - input array -* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension -* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions -* @returns {ndarray} output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -function tile( x, reps ) { - var dtype; - var order; - var shx; - var sho; - var shi; - var sto; - var buf; - var len; - var out; - var Ds; - var si; - var sx; - var v1; - var v2; - var M; - var N; - var o; - var s; - var t; - var i; - var j; - var k; - - shx = getShape( x, false ); - sx = getStrides( x, false ); - dtype = getDType( x ); - N = reps.length; - M = shx.length; - - if ( N < M ) { - throw new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) ); - } - // Compute the implicit left-padding amount for the input shape: - Ds = N - M; - - o = strides2order( sx ); - if ( o === 0 || o === 3 ) { - // Fallback to stated layout when unable to infer the underlying physical layout: - order = getOrder( x ); - } else if ( o === 1 ) { - order = 'row-major'; - } else { - order = 'column-major'; - } - // Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy... - shi = zeros( 2*N ); - si = zeros( 2*N ); - sho = zeros( N ); - for ( i = 0; i < N; i++ ) { - j = i - Ds; - k = 2 * i; - s = ( j < 0 ) ? 1 : shx[ j ]; - t = ( j < 0 ) ? 0 : sx[ j ]; - sho[ i ] = reps[ i ] * s; - if ( order === 'row-major' ) { - shi[ k ] = reps[ i ]; - shi[ k+1 ] = s; - si[ k+1 ] = t; - } else { // order === 'column-major' - shi[ k ] = s; - shi[ k+1 ] = reps[ i ]; - si[ k ] = t; - } - } - if ( N > 0 ) { - len = numel( sho ); - sto = shape2strides( sho, order ); - } else { - len = 1; - sto = [ 0 ]; - } - // Allocate an output array: - buf = buffer( dtype, len ); - out = new x.constructor( dtype, buf, sho, sto, 0, order ); - - // Create a "broadcasted" input 2N-D view over the data buffers: - v1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order ); - v2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order ); - - // Copy the elements to the output array: - assign( [ v1, v2 ] ); - - return out; -} - - -// EXPORTS // - -module.exports = tile; diff --git a/package.json b/package.json index e7ff721..f26f289 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Construct a new ndarray by repeating the elements of an input ndarray a specified number of times along each dimension.", "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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/ndarray-base-assign": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "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.3" - }, - "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..329f9b2 --- /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 7702356..0000000 --- a/test/test.js +++ /dev/null @@ -1,644 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var base = require( '@stdlib/ndarray-base-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var tile = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof tile, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tiles an input array (row-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (row-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if the number of repetitions is less than the number of input dimensions', function test( t ) { - var values; - var x; - var i; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - - values = [ - [], - [ 2 ], - [ 2, 2 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - tile( x, value ); - }; - } -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ] ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2 ], [ 2, 1 ], [ 1, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1 ], [ 2 ] ] ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3 ], [ 3 ], [ 1 ], 0, 'row-major' ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ 1, 2, 3 ] ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function infers the output layout from the input strides (non-monotonic strides)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], [ 2, 3, 2 ], [ 2, 4, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 5, 6, 5, 6 ], - [ 9, 10, 9, 10 ] - ], - [ - [ 3, 4, 3, 4 ], - [ 7, 8, 7, 8 ], - [ 11, 12, 11, 12 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (base)', function test( t ) { - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (non-base)', function test( t ) { - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); From b17102fe130f81e58a73f0cc7258ba2427e6b94e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:24:59 +0000 Subject: [PATCH 12/14] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index bff6014..acadcde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -33,7 +33,7 @@ var getOrder = require( '@stdlib/ndarray-base-order' ); var getDType = require( '@stdlib/ndarray-base-dtype' ); var getData = require( '@stdlib/ndarray-base-data-buffer' ); var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // diff --git a/package.json b/package.json index 140a458..e7ff721 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/ndarray-base-shape2strides": "^0.2.3", "@stdlib/ndarray-base-strides": "^0.2.3", "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 218d1d0e2236ccc998b682f2b361b416d152a64e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:49:18 +0000 Subject: [PATCH 13/14] Remove files --- index.d.ts | 52 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4899 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 593dd28..0000000 --- a/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ArrayLike } from '@stdlib/types/array'; -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param x - input array -* @param reps - number of repetitions along each dimension -* @returns output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -declare function tile( x: T, reps: ArrayLike ): T; - - -// EXPORTS // - -export = tile; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fb9dfa1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbbd597..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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 329f9b2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9a8d44924594f865c0b1a523d1598f513bad3793 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:49:49 +0000 Subject: [PATCH 14/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .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 | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 115 - benchmark/benchmark.ndims.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 35 - docs/types/test.ts | 82 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 44 - lib/main.js | 152 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 644 --- 45 files changed, 4867 insertions(+), 4894 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.ndims.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 (95%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +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 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# 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 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +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 - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 56fb41a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-19T03:20:37.952Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3e13666..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/base/tile) 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 ad10d2a..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/base/tile) 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 7244d1e..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: '52 16 * * 2' - - # 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 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +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 notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # 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 + + ```
@@ -160,7 +151,7 @@ console.log( ndarray2array( out ) ); ## 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]. @@ -223,7 +214,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-tile/main/LICENSE -[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor +[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray-base-ctor/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 833fada..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float64Array = require( '@stdlib/array-float64' ); -var ndarrayBase = require( '@stdlib/ndarray-base-ctor' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::ctor=base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ), - ndarrayBase( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::ctor=non-base,ndims=2,order=row-major', pkg ), function benchmark( b ) { - var strides; - var values; - var buffer; - var offset; - var dtype; - var shape; - var order; - var out; - var i; - - dtype = 'float64'; - buffer = new Float64Array( 4 ); - shape = [ 2, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - values = [ - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ), - ndarray( dtype, buffer, shape, strides, offset, order ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( values[ i%values.length ], [ 2, 2 ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.ndims.js b/benchmark/benchmark.ndims.js deleted file mode 100644 index a4e711b..0000000 --- a/benchmark/benchmark.ndims.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 array = require( '@stdlib/ndarray-array' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var tile = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} ndims - number of output dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( ndims ) { - var reps; - var x; - var i; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - reps = []; - for ( i = 0; i < ndims; i++ ) { - reps.push( 1 ); - } - reps[ ndims-1 ] = 2; - if ( ndims >= 2 ) { - reps[ ndims-2 ] = 2; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = tile( x, reps ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 2; - max = 10; - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( format( '%s::ctor=non-base,ndims=%d,order=row-major', pkg, i ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index a7de45a..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/base/tile" -%% click B href "https://github.com/stdlib-js/ndarray-base-tile/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-tile/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-tile/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-tile/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-tile/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/tile -[production-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-tile/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-tile/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-tile/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 1951865..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import tile from '../docs/types/index'; -export = tile; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 04118a2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var E=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(s){throw r=0,s}}};var z=E(function(Q,k){"use strict";var S=require("@stdlib/ndarray-base-ctor"),M=require("@stdlib/ndarray-base-assign"),R=require("@stdlib/ndarray-base-buffer"),T=require("@stdlib/ndarray-base-numel"),O=require("@stdlib/ndarray-base-shape2strides"),A=require("@stdlib/ndarray-base-strides2order"),B=require("@stdlib/ndarray-base-shape"),C=require("@stdlib/ndarray-base-strides"),F=require("@stdlib/ndarray-base-offset"),G=require("@stdlib/ndarray-base-order"),H=require("@stdlib/ndarray-base-dtype"),I=require("@stdlib/ndarray-base-data-buffer"),w=require("@stdlib/array-base-zeros"),J=require("@stdlib/string-format");function K(e,r){var s,a,g,o,v,d,h,c,j,y,f,b,D,N,m,t,l,q,p,i,n,u;if(g=B(e,!1),b=C(e,!1),s=H(e),t=r.length,m=g.length,t0?(c=T(o),d=O(o,a)):(c=1,d=[0]),h=R(s,c),j=new e.constructor(s,h,o,d,0,a),D=S(s,I(e),v,f,F(e),a),N=S(s,h,v,O(v,a),0,a),M([D,N]),j}k.exports=K});var L=z();module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 59f9588..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) 2026 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 ndarray = require( '@stdlib/ndarray-base-ctor' );\nvar assign = require( '@stdlib/ndarray-base-assign' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar getShape = require( '@stdlib/ndarray-base-shape' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = tile;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 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* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* @module @stdlib/ndarray-base-tile\n*\n* @example\n* var array = require( '@stdlib/ndarray-array' );\n* var tile = require( '@stdlib/ndarray-base-tile' );\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,2BAA4B,EAC/CC,EAAS,QAAS,6BAA8B,EAChDC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAW,QAAS,4BAA6B,EACjDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAAMC,EAAGC,EAAO,CACxB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACAC,EACAC,EAQJ,GANAlB,EAAMb,EAAUS,EAAG,EAAM,EACzBa,EAAKrB,EAAYQ,EAAG,EAAM,EAC1BE,EAAQP,EAAUK,CAAE,EACpBiB,EAAIhB,EAAK,OACTe,EAAIZ,EAAI,OAEHa,EAAID,EACR,MAAM,IAAI,WAAYlB,EAAQ,0LAA2LkB,EAAGC,CAAE,CAAE,EAkBjO,IAfAN,EAAKM,EAAID,EAETE,EAAI5B,EAAeuB,CAAG,EACjBK,IAAM,GAAKA,IAAM,EAErBf,EAAQT,EAAUM,CAAE,EACTkB,IAAM,EACjBf,EAAQ,YAERA,EAAQ,eAGTG,EAAMT,EAAO,EAAEoB,CAAE,EACjBL,EAAKf,EAAO,EAAEoB,CAAE,EAChBZ,EAAMR,EAAOoB,CAAE,EACT,EAAI,EAAG,EAAIA,EAAG,IACnBI,EAAI,EAAIV,EACRW,EAAI,EAAI,EACRH,EAAME,EAAI,EAAM,EAAIjB,EAAKiB,CAAE,EAC3BD,EAAMC,EAAI,EAAM,EAAIR,EAAIQ,CAAE,EAC1BhB,EAAK,CAAE,EAAIJ,EAAM,CAAE,EAAIkB,EAClBhB,IAAU,aACdG,EAAKgB,CAAE,EAAIrB,EAAM,CAAE,EACnBK,EAAKgB,EAAE,CAAE,EAAIH,EACbP,EAAIU,EAAE,CAAE,EAAIF,IAEZd,EAAKgB,CAAE,EAAIH,EACXb,EAAKgB,EAAE,CAAE,EAAIrB,EAAM,CAAE,EACrBW,EAAIU,CAAE,EAAIF,GAGZ,OAAKH,EAAI,GACRR,EAAMrB,EAAOiB,CAAI,EACjBE,EAAMlB,EAAegB,EAAKF,CAAM,IAEhCM,EAAM,EACNF,EAAM,CAAE,CAAE,GAGXC,EAAMrB,EAAQe,EAAOO,CAAI,EACzBC,EAAM,IAAIV,EAAE,YAAaE,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,CAAM,EAGxDW,EAAK7B,EAASiB,EAAON,EAASI,CAAE,EAAGM,EAAKM,EAAInB,EAAWO,CAAE,EAAGG,CAAM,EAClEY,EAAK9B,EAASiB,EAAOM,EAAKF,EAAKjB,EAAeiB,EAAKH,CAAM,EAAG,EAAGA,CAAM,EAGrEjB,EAAQ,CAAE4B,EAAIC,CAAG,CAAE,EAEZL,CACR,CAKA1B,EAAO,QAAUe,ICjHjB,IAAIwB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "ndarray", "assign", "buffer", "numel", "shape2strides", "strides2order", "getShape", "getStrides", "getOffset", "getOrder", "getDType", "getData", "zeros", "format", "tile", "x", "reps", "dtype", "order", "shx", "sho", "shi", "sto", "buf", "len", "out", "Ds", "si", "sx", "v1", "v2", "M", "N", "o", "s", "t", "j", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 339b8f8..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, reps ) - Returns an ndarray created by repeating the elements of an input ndarray - a specified number of times along each dimension. - - The number of repetitions must have at least as many elements as the number - of input dimensions. When the number of repetitions exceeds the number of - input dimensions, the input array is treated as if singleton dimensions - were prepended. - - The function always copies data to a new ndarray. - - Parameters - ---------- - x: ndarray - Input array. - - reps: ArrayLikeObject - Number of repetitions along each dimension. - - Returns - ------- - out: ndarray - Output array. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 1, 2 ], [ 3, 4 ] ] - > var o = {{alias}}( x, [ 2, 2 ] ) - [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a7281a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 space-in-parens */ - -/// - -import zeros = require( '@stdlib/ndarray-zeros' ); -import tile = require( './index' ); - - -// TESTS // - -// The function returns an ndarray having the same type as the input ndarray... -{ - tile( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), [ 2, 2 ] ); // $ExpectType float64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), [ 2, 2 ] ); // $ExpectType float32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), [ 2, 2 ] ); // $ExpectType complex128ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), [ 2, 2 ] ); // $ExpectType complex64ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), [ 2, 2 ] ); // $ExpectType int32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), [ 2, 2 ] ); // $ExpectType int16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), [ 2, 2 ] ); // $ExpectType int8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), [ 2, 2 ] ); // $ExpectType uint32ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), [ 2, 2 ] ); // $ExpectType uint16ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), [ 2, 2 ] ); // $ExpectType uint8ndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), [ 2, 2 ] ); // $ExpectType uint8cndarray - tile( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), [ 2, 2 ] ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function is not provided a first argument which is an ndarray... -{ - tile( '5', [ 2, 2, 2 ] ); // $ExpectError - tile( 5, [ 2, 2, 2 ] ); // $ExpectError - tile( true, [ 2, 2, 2 ] ); // $ExpectError - tile( false, [ 2, 2, 2 ] ); // $ExpectError - tile( null, [ 2, 2, 2 ] ); // $ExpectError - tile( {}, [ 2, 2, 2 ] ); // $ExpectError - tile( [ '5' ], [ 2, 2, 2 ] ); // $ExpectError - tile( ( x: number ): number => x, [ 2, 2, 2 ] ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a second argument which is an array-like object containing numbers... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile( x, '5' ); // $ExpectError - tile( x, 5 ); // $ExpectError - tile( x, true ); // $ExpectError - tile( x, false ); // $ExpectError - tile( x, null ); // $ExpectError - tile( x, {} ); // $ExpectError - tile( x, [ '5' ] ); // $ExpectError - tile( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ], { - 'dtype': 'float64' - }); - - tile(); // $ExpectError - tile( x ); // $ExpectError - tile( x, [ 1, 2, 3 ], [ 2, 3 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 9f5a156..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var tile = require( './../lib' ); - -// Create a 2x2 array: -var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -console.log( ndarray2array( x ) ); - -// Tile the array to 4x4: -var out = tile( x, [ 2, 2 ] ); -console.log( ndarray2array( out ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b7c32af..593dd28 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fb9dfa1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 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/ndarray-base-ctor@v0.3.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assign@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-numel@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function b(b,v){var f,g,c,u,x,y,w,N,z,E,R,S,k,q,A,B,C,D,F,G,H,I;if(c=m(b,!1),S=i(b,!1),f=j(b),(B=v.length)<(A=c.length))throw new RangeError(p("invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.",A,B));for(E=B-A,g=0===(C=n(S))||3===C?o(b):1===C?"row-major":"column-major",x=h(2*B),R=h(2*B),u=h(B),G=0;G0?(N=t(u),y=d(u,g)):(N=1,y=[0]),w=r(f,N),z=new b.constructor(f,w,u,y,0,g),k=s(f,l(b),x,R,a(b),g),q=s(f,w,x,d(x,g),0,g),e([k,q]),z}export{b as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbbd597 --- /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) 2026 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 ndarray from '@stdlib/ndarray-base-ctor';\nimport assign from '@stdlib/ndarray-base-assign';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport numel from '@stdlib/ndarray-base-numel';\nimport shape2strides from '@stdlib/ndarray-base-shape2strides';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport getShape from '@stdlib/ndarray-base-shape';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport zeros from '@stdlib/array-base-zeros';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension.\n*\n* ## Notes\n*\n* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended.\n* - The function always copies data to a new ndarray.\n*\n* @param {ndarray} x - input array\n* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension\n* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions\n* @returns {ndarray} output array\n*\n* @example\n* import array from '@stdlib/ndarray-array';\n*\n* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*\n* var y = tile( x, [ 2, 2 ] );\n* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ]\n*/\nfunction tile( x, reps ) {\n\tvar dtype;\n\tvar order;\n\tvar shx;\n\tvar sho;\n\tvar shi;\n\tvar sto;\n\tvar buf;\n\tvar len;\n\tvar out;\n\tvar Ds;\n\tvar si;\n\tvar sx;\n\tvar v1;\n\tvar v2;\n\tvar M;\n\tvar N;\n\tvar o;\n\tvar s;\n\tvar t;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tshx = getShape( x, false );\n\tsx = getStrides( x, false );\n\tdtype = getDType( x );\n\tN = reps.length;\n\tM = shx.length;\n\n\tif ( N < M ) {\n\t\tthrow new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) );\n\t}\n\t// Compute the implicit left-padding amount for the input shape:\n\tDs = N - M;\n\n\to = strides2order( sx );\n\tif ( o === 0 || o === 3 ) {\n\t\t// Fallback to stated layout when unable to infer the underlying physical layout:\n\t\torder = getOrder( x );\n\t} else if ( o === 1 ) {\n\t\torder = 'row-major';\n\t} else {\n\t\torder = 'column-major';\n\t}\n\t// Compute an interleaved 2N-D shape and strides for \"broadcasting\" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...\n\tshi = zeros( 2*N );\n\tsi = zeros( 2*N );\n\tsho = zeros( N );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = i - Ds;\n\t\tk = 2 * i;\n\t\ts = ( j < 0 ) ? 1 : shx[ j ];\n\t\tt = ( j < 0 ) ? 0 : sx[ j ];\n\t\tsho[ i ] = reps[ i ] * s;\n\t\tif ( order === 'row-major' ) {\n\t\t\tshi[ k ] = reps[ i ];\n\t\t\tshi[ k+1 ] = s;\n\t\t\tsi[ k+1 ] = t;\n\t\t} else { // order === 'column-major'\n\t\t\tshi[ k ] = s;\n\t\t\tshi[ k+1 ] = reps[ i ];\n\t\t\tsi[ k ] = t;\n\t\t}\n\t}\n\tif ( N > 0 ) {\n\t\tlen = numel( sho );\n\t\tsto = shape2strides( sho, order );\n\t} else {\n\t\tlen = 1;\n\t\tsto = [ 0 ];\n\t}\n\t// Allocate an output array:\n\tbuf = buffer( dtype, len );\n\tout = new x.constructor( dtype, buf, sho, sto, 0, order );\n\n\t// Create a \"broadcasted\" input 2N-D view over the data buffers:\n\tv1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order );\n\tv2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order );\n\n\t// Copy the elements to the output array:\n\tassign( [ v1, v2 ] );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default tile;\n"],"names":["tile","x","reps","dtype","order","shx","sho","shi","sto","buf","len","out","Ds","si","sx","v1","v2","M","N","o","s","t","i","j","k","getShape","getStrides","getDType","length","RangeError","format","strides2order","getOrder","zeros","numel","shape2strides","buffer","constructor","ndarray","getData","getOffset","assign"],"mappings":";;kzCA8DA,SAASA,EAAMC,EAAGC,GACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAQJ,GANAnB,EAAMoB,EAAUxB,GAAG,GACnBa,EAAKY,EAAYzB,GAAG,GACpBE,EAAQwB,EAAU1B,IAClBiB,EAAIhB,EAAK0B,SACTX,EAAIZ,EAAIuB,QAGP,MAAM,IAAIC,WAAYC,EAAQ,0LAA2Lb,EAAGC,IAkB7N,IAfAN,EAAKM,EAAID,EAKRb,EAFU,KADXe,EAAIY,EAAejB,KACG,IAANK,EAEPa,EAAU/B,GACD,IAANkB,EACH,YAEA,eAGTZ,EAAM0B,EAAO,EAAEf,GACfL,EAAKoB,EAAO,EAAEf,GACdZ,EAAM2B,EAAOf,GACPI,EAAI,EAAGA,EAAIJ,EAAGI,IAEnBE,EAAI,EAAIF,EACRF,GAFAG,EAAID,EAAIV,GAEE,EAAM,EAAIP,EAAKkB,GACzBF,EAAME,EAAI,EAAM,EAAIT,EAAIS,GACxBjB,EAAKgB,GAAMpB,EAAMoB,GAAMF,EACR,cAAVhB,GACJG,EAAKiB,GAAMtB,EAAMoB,GACjBf,EAAKiB,EAAE,GAAMJ,EACbP,EAAIW,EAAE,GAAMH,IAEZd,EAAKiB,GAAMJ,EACXb,EAAKiB,EAAE,GAAMtB,EAAMoB,GACnBT,EAAIW,GAAMH,GAqBZ,OAlBKH,EAAI,GACRR,EAAMwB,EAAO5B,GACbE,EAAM2B,EAAe7B,EAAKF,KAE1BM,EAAM,EACNF,EAAM,CAAE,IAGTC,EAAM2B,EAAQjC,EAAOO,GACrBC,EAAM,IAAIV,EAAEoC,YAAalC,EAAOM,EAAKH,EAAKE,EAAK,EAAGJ,GAGlDW,EAAKuB,EAASnC,EAAOoC,EAAStC,GAAKM,EAAKM,EAAI2B,EAAWvC,GAAKG,GAC5DY,EAAKsB,EAASnC,EAAOM,EAAKF,EAAK4B,EAAe5B,EAAKH,GAAS,EAAGA,GAG/DqC,EAAQ,CAAE1B,EAAIC,IAEPL,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e446fd8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* @module @stdlib/ndarray-base-tile -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* var tile = require( '@stdlib/ndarray-base-tile' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ - -// 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 acadcde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ndarray = require( '@stdlib/ndarray-base-ctor' ); -var assign = require( '@stdlib/ndarray-base-assign' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var getShape = require( '@stdlib/ndarray-base-shape' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an ndarray created by repeating the elements of an input ndarray a specified number of times along each dimension. -* -* ## Notes -* -* - The number of repetitions must have at least as many elements as the number of input dimensions. When the number of repetitions exceeds the number of input dimensions, the input array is treated as if singleton dimensions were prepended. -* - The function always copies data to a new ndarray. -* -* @param {ndarray} x - input array -* @param {NonNegativeIntegerArray} reps - number of repetitions along each dimension -* @throws {RangeError} second argument must have at least as many elements as the number of input dimensions -* @returns {ndarray} output array -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -* -* var y = tile( x, [ 2, 2 ] ); -* // returns [ [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ], [ 1, 2, 1, 2 ], [ 3, 4, 3, 4 ] ] -*/ -function tile( x, reps ) { - var dtype; - var order; - var shx; - var sho; - var shi; - var sto; - var buf; - var len; - var out; - var Ds; - var si; - var sx; - var v1; - var v2; - var M; - var N; - var o; - var s; - var t; - var i; - var j; - var k; - - shx = getShape( x, false ); - sx = getStrides( x, false ); - dtype = getDType( x ); - N = reps.length; - M = shx.length; - - if ( N < M ) { - throw new RangeError( format( 'invalid argument. Second argument must have at least as many elements as the number of dimensions of the first argument. Number of input dimensions: `%u`. Number of repetitions: `%u`.', M, N ) ); - } - // Compute the implicit left-padding amount for the input shape: - Ds = N - M; - - o = strides2order( sx ); - if ( o === 0 || o === 3 ) { - // Fallback to stated layout when unable to infer the underlying physical layout: - order = getOrder( x ); - } else if ( o === 1 ) { - order = 'row-major'; - } else { - order = 'column-major'; - } - // Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy... - shi = zeros( 2*N ); - si = zeros( 2*N ); - sho = zeros( N ); - for ( i = 0; i < N; i++ ) { - j = i - Ds; - k = 2 * i; - s = ( j < 0 ) ? 1 : shx[ j ]; - t = ( j < 0 ) ? 0 : sx[ j ]; - sho[ i ] = reps[ i ] * s; - if ( order === 'row-major' ) { - shi[ k ] = reps[ i ]; - shi[ k+1 ] = s; - si[ k+1 ] = t; - } else { // order === 'column-major' - shi[ k ] = s; - shi[ k+1 ] = reps[ i ]; - si[ k ] = t; - } - } - if ( N > 0 ) { - len = numel( sho ); - sto = shape2strides( sho, order ); - } else { - len = 1; - sto = [ 0 ]; - } - // Allocate an output array: - buf = buffer( dtype, len ); - out = new x.constructor( dtype, buf, sho, sto, 0, order ); - - // Create a "broadcasted" input 2N-D view over the data buffers: - v1 = ndarray( dtype, getData( x ), shi, si, getOffset( x ), order ); - v2 = ndarray( dtype, buf, shi, shape2strides( shi, order ), 0, order ); - - // Copy the elements to the output array: - assign( [ v1, v2 ] ); - - return out; -} - - -// EXPORTS // - -module.exports = tile; diff --git a/package.json b/package.json index e7ff721..f26f289 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Construct a new ndarray by repeating the elements of an input ndarray a specified number of times along each dimension.", "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,53 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/ndarray-base-assign": "^0.2.1", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-numel": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-shape": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-strides2order": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "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.3" - }, - "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..329f9b2 --- /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 7702356..0000000 --- a/test/test.js +++ /dev/null @@ -1,644 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array = require( '@stdlib/ndarray-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var base = require( '@stdlib/ndarray-base-ctor' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var tile = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof tile, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tiles an input array (row-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (row-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (negative strides, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ -2, -1 ], 3, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ], - [ 4, 3, 4, 3 ], - [ 2, 1, 2, 1 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array (non-contiguous, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2 ], [ 4, 2 ], 1, 'row-major' ); - y = tile( x, [ 2, 2 ] ); - - expected = [ - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ], - [ 2, 4, 2, 4 ], - [ 6, 8, 6, 8 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 3, 2, 4 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function prepends singleton dimensions when the number of repetitions exceeds the number of input dimensions (column-major, non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ], { - 'order': 'column-major' - }); - y = tile( x, [ 3, 2, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ], - [ - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ], - [ 1, 2, 1, 2 ], - [ 3, 4, 3, 4 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 3, 4, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if the number of repetitions is less than the number of input dimensions', function test( t ) { - var values; - var x; - var i; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - - values = [ - [], - [ 2 ], - [ 2, 2 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - tile( x, value ); - }; - } -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8 ], [ 2, 2, 2 ], [ 4, 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array when all repetitions are equal to one (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ] ); - y = tile( x, [ 1, 1, 1 ] ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2 ], [ 2, 1 ], [ 1, 1 ], 0, 'row-major' ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles an input array along singleton dimensions (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ [ 1 ], [ 2 ] ] ); - y = tile( x, [ 2, 3 ] ); - - expected = [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 4, 3 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a zero-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = ndarray( 'generic', [ 5 ], [], [ 0 ], 0, 'row-major' ); - y = tile( x, [ 2, 3, 4 ] ); - - expected = [ - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ], - [ [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ], [ 5, 5, 5, 5 ] ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - // Empty repetitions yield a zero-dimensional output: - y = tile( x, [] ); - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [], 'returns expected value' ); - t.strictEqual( y.get(), 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (base)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3 ], [ 3 ], [ 1 ], 0, 'row-major' ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tiles a one-dimensional input array (non-base)', function test( t ) { - var expected; - var x; - var y; - - x = array( [ 1, 2, 3 ] ); - y = tile( x, [ 2 ] ); - - expected = [ 1, 2, 3, 1, 2, 3 ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 6 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function infers the output layout from the input strides (non-monotonic strides)', function test( t ) { - var expected; - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ], [ 2, 3, 2 ], [ 2, 4, 1 ], 0, 'row-major' ); - y = tile( x, [ 1, 1, 2 ] ); - - expected = [ - [ - [ 1, 2, 1, 2 ], - [ 5, 6, 5, 6 ], - [ 9, 10, 9, 10 ] - ], - [ - [ 3, 4, 3, 4 ], - [ 7, 8, 7, 8 ], - [ 11, 12, 11, 12 ] - ] - ]; - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 2, 3, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( y ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (base)', function test( t ) { - var x; - var y; - - x = base( 'generic', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, base ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty ndarray when a repetition is zero (non-base)', function test( t ) { - var x; - var y; - - x = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - y = tile( x, [ 0, 2 ] ); - - t.notEqual( y, x, 'returns expected value' ); - t.notEqual( getData( y ), getData( x ), 'returns expected value' ); - t.strictEqual( instanceOf( y, ndarray ), true, 'returns expected value' ); - t.deepEqual( getShape( y ), [ 0, 4 ], 'returns expected value' ); - t.strictEqual( numel( getShape( y ) ), 0, 'returns expected value' ); - - t.end(); -});